postgres=# \d a_long_table_name_with_exactly_sixty_three_characters_testtbl01 Partitioned table "public.a_long_table_name_with_exactly_sixty_three_characters_testtbl01" Column| Type |Collation| Nullable |Default --------+-----------------------------+-----------+----------+--------- id |integer||| info | text ||| t_time |timestampwithouttime zone ||| Partition key: RANGE (t_time) Number of partitions: 2 (Use \d+to list them.)
然后为子表添加索引:
1 2 3 4 5 6 7 8 9
postgres=# begin; BEGIN postgres=*# create index on a_long_table_name_with_exactly_sixty_three_characters_test_par1(id,info); CREATE INDEX postgres=*# select pg_backend_pid(); pg_backend_pid ---------------- 12212 (1row)
另一个会话同样添加索引,会莫名发现被卡主,操作的明明是两个对象:
1 2 3 4 5 6 7 8 9 10
postgres=# begin; BEGIN postgres=*# select pg_backend_pid(); pg_backend_pid ---------------- 12322 (1row)
postgres=*# create index on a_long_table_name_with_exactly_sixty_three_characters_test_par2(id,info); ---此处卡住
postgres=# begin; BEGIN postgres=*# create index on a_long_table_name_with_exactly_sixty_three_characters_test_par1(id,info); CREATE INDEX postgres=*# \d a_long_table_name_with_exactly_sixty_three_characters_test_par1 Table "public.a_long_table_name_with_exactly_sixty_three_characters_test_par1" Column| Type |Collation| Nullable |Default --------+-----------------------------+-----------+----------+--------- id |integer||| info | text ||| t_time |timestampwithouttime zone ||| Partitionof: a_long_table_name_with_exactly_sixty_three_characters_testtbl01 FORVALUESFROM ('2023-01-01 00:00:00') TO ('2024-01-01 00:00:00') Indexes: "a_long_table_name_with_exactly_sixty_three_characte_id_info_idx" btree (id, info)
postgres=# begin; BEGIN postgres=*# create table long_long_long_long_long_longlong_long_longlong_long_longlong_long_long(id int); NOTICE: identifier "long_long_long_long_long_longlong_long_longlong_long_longlong_long_long" will be truncated to "long_long_long_long_long_longlong_long_longlong_long_longlong_l" CREATE TABLE