提交 98c9cfb4 编写于 作者: H Heikki Linnakangas

Move tests on partition pruning from TINC.

We had very similar tests in the "partition_pruning" test, even with the
same test table, so that's a natural home for this too.

I left out the "alter_tab_add_pkey" tests, because they were identical to
the "alter_tab_add_uniquekey" tests, except that the index was created for
a PRIMARY KEY rather than a UNIQUE constraint. I don't see the point of
that. Furthermore, the test queries in "alter_tab_add_pkey" didn't actually
make use of the index.
上级 0e0744a0
......@@ -728,6 +728,207 @@ DROP INDEX idx1_1_prt_part2;
DROP INDEX idx1_1_prt_part3;
DROP INDEX idx1_1_prt_part4;
DROP INDEX idx1_1_prt_part5;
-- @description multi-column unique constraint (= b-tree index). Essentially the
-- same as the previous case, but the columns are the other way 'round, and we
-- do this on the table with default partition.
ALTER TABLE pt_lt_tab_df ADD CONSTRAINT col2_col1_unique unique(col2,col1);
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_col2_key" for table "pt_lt_tab_df"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_part1_col2_key" for table "pt_lt_tab_df_1_prt_part1"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_part2_col2_key" for table "pt_lt_tab_df_1_prt_part2"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_part3_col2_key" for table "pt_lt_tab_df_1_prt_part3"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_part4_col2_key" for table "pt_lt_tab_df_1_prt_part4"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_part5_col2_key" for table "pt_lt_tab_df_1_prt_part5"
NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_df_1_prt_def_col2_key" for table "pt_lt_tab_df_1_prt_def"
SELECT * FROM pt_lt_tab_df WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
1 | 1 | a | t
2 | 2 | a | t
3 | 3 | a | t
4 | 4 | b | t
5 | 5 | b | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..18.31 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..18.31 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..18.31 rows=2 width=14)
-> Sort (cost=0.00..18.31 rows=4 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..18.31 rows=4 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Partitions selected: 6 (out of 6)
-> Dynamic Index Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..18.31 rows=4 width=14)
Index Cond: col1 < 10
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(13 rows)
SELECT * FROM pt_lt_tab_df WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
51 | 51 | u | t
52 | 52 | u | t
53 | 53 | u | t
54 | 54 | x | t
55 | 55 | x | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..18.31 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..18.31 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..18.31 rows=2 width=14)
-> Sort (cost=0.00..18.31 rows=4 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..18.31 rows=4 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Partitions selected: 6 (out of 6)
-> Dynamic Index Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..18.31 rows=4 width=14)
Index Cond: col1 > 50
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(13 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
25 | 25 | k | f
(1 row)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..2.00 rows=1 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..2.00 rows=1 width=14)
Merge Key: col2, col3
-> Sort (cost=0.00..2.00 rows=1 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..2.00 rows=1 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Filter: col2 = 25::numeric
Partitions selected: 1 (out of 6)
-> Dynamic Index Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..2.00 rows=1 width=14)
Index Cond: col2 = 25::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(13 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
1 | 1 | a | t
2 | 2 | a | t
3 | 3 | a | t
4 | 4 | b | t
5 | 5 | b | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.01 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.01 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..431.01 rows=2 width=14)
-> Sort (cost=0.00..431.01 rows=21 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.00 rows=21 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Filter: col2 < 10::numeric OR col2 > 10::numeric
Partitions selected: 6 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=21 width=14)
Filter: col2 <> 10::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(14 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
(0 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..6.00 rows=1 width=14)
-> Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..6.00 rows=1 width=14)
Merge Key: col2, col3
-> Sort (cost=0.00..6.00 rows=1 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..6.00 rows=1 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Filter: col2 > 10::numeric
Partitions selected: 5 (out of 6)
-> Dynamic Index Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..6.00 rows=1 width=14)
Index Cond: col2 > 10::numeric AND col1 = 10
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(13 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 > 10.00 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
11 | 11 | e | t
12 | 12 | e | t
13 | 13 | e | t
14 | 14 | f | t
15 | 15 | f | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 10.00 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.01 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.01 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..431.01 rows=2 width=14)
-> Sort (cost=0.00..431.01 rows=18 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.00 rows=18 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Partitions selected: 6 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=18 width=14)
Filter: col2 > 10.00 OR col1 = 50
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(13 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
10 | 10 | c | t
11 | 11 | e | t
12 | 12 | e | t
13 | 13 | e | t
14 | 14 | f | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..83.27 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..83.27 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..83.27 rows=2 width=14)
-> Sort (cost=0.00..83.27 rows=14 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..83.27 rows=14 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Filter: col2 >= 10::numeric AND col2 <= 50::numeric
Partitions selected: 6 (out of 6)
-> Dynamic Index Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..83.27 rows=14 width=14)
Index Cond: col2 >= 10::numeric AND col2 <= 50::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.48.2
(14 rows)
ALTER TABLE pt_lt_tab_df DROP CONSTRAINT col2_col1_unique;
-- @description Heterogeneous index, index on partition key, b-tree index on all partitions
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_1_prt_part2(col2);
......
......@@ -199,6 +199,30 @@ DROP INDEX idx1_1_prt_part4;
DROP INDEX idx1_1_prt_part5;
-- @description multi-column unique constraint (= b-tree index). Essentially the
-- same as the previous case, but the columns are the other way 'round, and we
-- do this on the table with default partition.
ALTER TABLE pt_lt_tab_df ADD CONSTRAINT col2_col1_unique unique(col2,col1);
SELECT * FROM pt_lt_tab_df WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 > 10.00 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 10.00 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
ALTER TABLE pt_lt_tab_df DROP CONSTRAINT col2_col1_unique;
-- @description Heterogeneous index, index on partition key, b-tree index on all partitions
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_1_prt_part2(col2);
......
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description ALTER TABLE, Unique index with Primary Key
ALTER TABLE pt_lt_tab ADD primary key(col2,col1);
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_pkey" for table "pt_lt_tab"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part1_pkey" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part2_pkey" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part3_pkey" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part4_pkey" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part5_pkey" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_pkey_4.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_def_pkey" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
1 | 1 | part1 | t
2 | 2 | part1 | t
3 | 3 | part1 | t
4 | 4 | part1 | t
5 | 5 | part1 | t
(5 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description ALTER TABLE, Unique index with Primary Key
ALTER TABLE pt_lt_tab ADD primary key(col2,col1);
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_pkey" for table "pt_lt_tab"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part1_pkey" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part2_pkey" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part3_pkey" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part4_pkey" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_part5_pkey" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_pkey_6.sql:7: NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pt_lt_tab_1_prt_def_pkey" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col2 > 10 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
11 | 11 | part2 | t
12 | 12 | part2 | t
13 | 13 | part2 | t
14 | 14 | part2 | t
15 | 15 | part2 | t
(5 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_col2_key" for table "pt_lt_tab"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part1_col2_key" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part2_col2_key" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part3_col2_key" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part4_col2_key" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part5_col2_key" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_uniquekey_3.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_def_col2_key" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
1 | 1 | part1 | t
2 | 2 | part1 | t
3 | 3 | part1 | t
4 | 4 | part1 | t
5 | 5 | part1 | t
(5 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_col2_key" for table "pt_lt_tab"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part1_col2_key" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part2_col2_key" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part3_col2_key" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part4_col2_key" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part5_col2_key" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_uniquekey_4.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_def_col2_key" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
51 | 51 | part6 | f
52 | 52 | part6 | f
53 | 53 | part6 | f
54 | 54 | part6 | f
55 | 55 | part6 | f
(5 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_col2_key" for table "pt_lt_tab"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part1_col2_key" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part2_col2_key" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part3_col2_key" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part4_col2_key" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part5_col2_key" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_uniquekey_5.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_def_col2_key" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
25 | 25 | part3 | f
(1 row)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_col2_key" for table "pt_lt_tab"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part1_col2_key" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part2_col2_key" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part3_col2_key" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part4_col2_key" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part5_col2_key" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_uniquekey_7.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_def_col2_key" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
(0 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_col2_key" for table "pt_lt_tab"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part1_col2_key" for table "pt_lt_tab_1_prt_part1"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part2_col2_key" for table "pt_lt_tab_1_prt_part2"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part3_col2_key" for table "pt_lt_tab_1_prt_part3"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part4_col2_key" for table "pt_lt_tab_1_prt_part4"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_part5_col2_key" for table "pt_lt_tab_1_prt_part5"
psql:alter_tab_add_uniquekey_9.sql:7: NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "pt_lt_tab_1_prt_def_col2_key" for table "pt_lt_tab_1_prt_def"
ALTER TABLE
SELECT * FROM pt_lt_tab WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
10 | 10 | part1 | t
11 | 11 | part2 | t
12 | 12 | part2 | t
13 | 13 | part2 | t
14 | 14 | part2 | t
(5 rows)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description ALTER TABLE, Unique index with Primary Key
ALTER TABLE pt_lt_tab ADD primary key(col2,col1);
SELECT * FROM pt_lt_tab WHERE col2 <> 10 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description ALTER TABLE, Unique index with Primary Key
ALTER TABLE pt_lt_tab ADD primary key(col2,col1);
SELECT * FROM pt_lt_tab WHERE col2 > 10 OR col1 = 50 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
SELECT * FROM pt_lt_tab WHERE col1 < 10 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
SELECT * FROM pt_lt_tab WHERE col1 > 50 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
SELECT * FROM pt_lt_tab WHERE col2 = 25 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
SELECT * FROM pt_lt_tab WHERE col2 > 10 AND col1 = 10 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @description ALTER TABLE, Unique index with Primary Key, unique index on the default partition
ALTER TABLE pt_lt_tab ADD unique(col2,col1);
SELECT * FROM pt_lt_tab WHERE col2 between 10 AND 50 ORDER BY col2,col3 LIMIT 5;
DROP TABLE IF EXISTS pt_lt_tab;
CREATE TABLE pt_lt_tab
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition def
);
INSERT INTO pt_lt_tab SELECT i, i,'part1',True FROM generate_series(1,10)i;
INSERT INTO pt_lt_tab SELECT i, i,'part2',True FROM generate_series(11,20)i;
INSERT INTO pt_lt_tab SELECT i, i,'part3',False FROM generate_series(21,30)i;
INSERT INTO pt_lt_tab SELECT i, i,'part4',False FROM generate_series(31,40)i;
INSERT INTO pt_lt_tab SELECT i, i,'part5',False FROM generate_series(41,50)i;
INSERT INTO pt_lt_tab SELECT i, i,'part6',False FROM generate_series(51,60)i;
ANALYZE pt_lt_tab;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册