PostgreSQL9.3Beta1:建表时废弃 "Implicit Index" 和 Sequence 的提示信息

9.3 版本之前,当创建表时,如果有隐式的索引或序列,那么会抛出 NOTICE 信息,新版本后这些 NOTICE 信息不再抛出,个人觉得这些信息在建表时不出现为好,日志看上去简捷点。

文档中说明

Suppress messages about implicit index and sequence creation (Robert Haas)
These messages now appear at DEBUG1 verbosity, so that they will not be shown by default.

备注:接着演示下。

9.2 版本创建表测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[pg92@redhatB ~]$ psql francs francs
psql (9.2.1)
Type "help" for help.

francs=> show client_min_messages;
client_min_messages
---------------------
notice
(1 row)

francs=> create table test_notice (id serial primary key ,name varchar(32));
NOTICE: CREATE TABLE will create implicit sequence "test_notice_id_seq" for serial column "test_notice.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_notice_pkey" for table "test_notice"
CREATE TABLE

francs=> \d test_notice
Table "francs.test_notice"
Column | Type | Modifiers
--------+-----------------------+----------------------------------------------------------
id | integer | not null default nextval('test_notice_id_seq'::regclass)
name | character varying(32) |
Indexes:
"test_notice_pkey" PRIMARY KEY, btree (id), tablespace "tbs_francs_idx"
Tablespace: "tbs_francs_idx"

备注:9.2 版本建表时抛出了隐式索引和序列信息。

9.3 版本创建表测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[pg93@redhatB ~]$ psql francs francs
psql (9.3beta1)
Type "help" for help.

francs=> show client_min_messages;
client_min_messages
---------------------
notice
(1 row)

francs=> create table test_notice (id serial primary key ,name varchar(32));
CREATE TABLE

francs=> \d test_notice
Table "francs.test_notice"
Column | Type | Modifiers
--------+-----------------------+----------------------------------------------------------
id | integer | not null default nextval('test_notice_id_seq'::regclass)
name | character varying(32) |
Indexes:
"test_notice_pkey" PRIMARY KEY, btree (id)

备注:9.3 版本建表时不再抛出隐式索引和序列信息,这类信息出现在 debug1 日志模式,因此也有方法查看这些信息。

设置 client_min_messages=’debug1’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[pg93@redhatB ~]$ psql francs francs
psql (9.3beta1)
Type "help" for help.

francs=> show client_min_messages;
client_min_messages
---------------------
notice
(1 row)

francs=> set client_min_messages='debug1';
SET

francs=> show client_min_messages;
client_min_messages
---------------------
debug1
(1 row)

francs=> create table test_notice2 (id serial primary key ,name varchar(32));
DEBUG: CREATE TABLE will create implicit sequence "test_notice2_id_seq" for serial column "test_notice2.id"
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_notice2_pkey" for table "test_notice2"
DEBUG: building index "test_notice2_pkey" on table "test_notice2"
CREATE TABLE

备注:设置 client_min_messages=’debug1’ 后,这类信息可以查看到了。

最后推荐和张文升共同编写的《PostgreSQL实战》,本书基于PostgreSQL 10 编写,共18章,重点介绍SQL高级特性、并行查询、分区表、物理复制、逻辑复制、备份恢复、高可用、性能优化、PostGIS等,涵盖大量实战用例!

购买链接:https://item.jd.com/12405774.html

PostgreSQL实战
感谢支持!
0%