Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

prepared statement can't choose partition? #46

Closed
@digoal

Description

create table test_pg_part_pathman(id int primary key, info text, crt_time timestamp);
ostgres=# select 
create_range_partitions('test_pg_part_pathman'::regclass, -- 主表OID
 'id', -- 分区列名
 1, -- 开始值
 1000000, -- 间隔
 20, -- 分多少个区
 true) ; -- 迁移数据
postgres=# select set_enable_parent('test_pg_part_pathman'::regclass, false);
postgres=# \d+ test_pg_part_pathman
 Table "public.test_pg_part_pathman"
 Column | Type | Modifiers | Storage | Stats target | Description 
----------+-----------------------------+-----------+----------+--------------+-------------
 id | integer | not null | plain | | 
 info | text | | extended | | 
 crt_time | timestamp without time zone | | plain | | 
Indexes:
 "test_pg_part_pathman_pkey" PRIMARY KEY, btree (id)
Child tables: test_pg_part_pathman_1,
 test_pg_part_pathman_10,
 test_pg_part_pathman_11,
 test_pg_part_pathman_12,
 test_pg_part_pathman_13,
 test_pg_part_pathman_14,
 test_pg_part_pathman_15,
 test_pg_part_pathman_16,
 test_pg_part_pathman_17,
 test_pg_part_pathman_18,
 test_pg_part_pathman_19,
 test_pg_part_pathman_2,
 test_pg_part_pathman_20,
 test_pg_part_pathman_3,
 test_pg_part_pathman_4,
 test_pg_part_pathman_5,
 test_pg_part_pathman_6,
 test_pg_part_pathman_7,
 test_pg_part_pathman_8,
 test_pg_part_pathman_9
postgres=# \d+ test_pg_part_pathman_1
 Table "public.test_pg_part_pathman_1"
 Column | Type | Modifiers | Storage | Stats target | Description 
----------+-----------------------------+-----------+----------+--------------+-------------
 id | integer | not null | plain | | 
 info | text | | extended | | 
 crt_time | timestamp without time zone | | plain | | 
Indexes:
 "test_pg_part_pathman_1_pkey" PRIMARY KEY, btree (id)
Check constraints:
 "pathman_test_pg_part_pathman_1_1_check" CHECK (id >= 1 AND id < 1000001)
Inherits: test_pg_part_pathman
postgres=# \d+ test_pg_part_pathman_10
 Table "public.test_pg_part_pathman_10"
 Column | Type | Modifiers | Storage | Stats target | Description 
----------+-----------------------------+-----------+----------+--------------+-------------
 id | integer | not null | plain | | 
 info | text | | extended | | 
 crt_time | timestamp without time zone | | plain | | 
Indexes:
 "test_pg_part_pathman_10_pkey" PRIMARY KEY, btree (id)
Check constraints:
 "pathman_test_pg_part_pathman_10_1_check" CHECK (id >= 9000001 AND id < 10000001)
Inherits: test_pg_part_pathman
postgres=# insert into test_pg_part_pathman select generate_series(1,20000000);
INSERT 0 20000000
Time: 61634.401 ms
postgres=# select count(*) from test_pg_part_orig;
 count 
----------
 20000000
(1 row)
Time: 1879.867 ms
postgres=# prepare p1(int) as select * from test_pg_part_pathman where id=1ドル;
PREPARE
postgres=# explain execute p1(1);
 QUERY PLAN 
-----------------------------------------------------------------------------------------------------------------
 Append (cost=0.42..2.44 rows=1 width=44)
 -> Index Scan using test_pg_part_pathman_1_pkey on test_pg_part_pathman_1 (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1)
(3 rows)
...
sixth:
postgres=# explain execute p1(2);
 QUERY PLAN 
----------------------------------------------------------------------------------------------------------------------------------------
 Custom Scan (RuntimeAppend) (cost=0.42..2.44 rows=1 width=44)
 -> Index Scan using test_pg_part_pathman_1_pkey on test_pg_part_pathman_1 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_2_pkey on test_pg_part_pathman_2 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_3_pkey on test_pg_part_pathman_3 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_4_pkey on test_pg_part_pathman_4 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_5_pkey on test_pg_part_pathman_5 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_6_pkey on test_pg_part_pathman_6 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_7_pkey on test_pg_part_pathman_7 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_8_pkey on test_pg_part_pathman_8 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_9_pkey on test_pg_part_pathman_9 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_10_pkey on test_pg_part_pathman_10 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_11_pkey on test_pg_part_pathman_11 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_12_pkey on test_pg_part_pathman_12 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_13_pkey on test_pg_part_pathman_13 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_14_pkey on test_pg_part_pathman_14 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_15_pkey on test_pg_part_pathman_15 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_16_pkey on test_pg_part_pathman_16 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_17_pkey on test_pg_part_pathman_17 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_18_pkey on test_pg_part_pathman_18 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_19_pkey on test_pg_part_pathman_19 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
 -> Index Scan using test_pg_part_pathman_20_pkey on test_pg_part_pathman_20 test_pg_part_pathman (cost=0.42..2.44 rows=1 width=44)
 Index Cond: (id = 1ドル)
(41 rows)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /