提交 fec9886b 编写于 作者: H Heikki Linnakangas

Move a couple more partition pruning/indexing tests from TINC.

上级 77e1206e
......@@ -1406,6 +1406,80 @@ DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
DROP INDEX idx6;
-- @description Negative tests Combination tests, no index on default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
CREATE INDEX idx4 on pt_lt_tab_df_1_prt_part4(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
52 | 52 | u | t
53 | 53 | u | t
54 | 54 | x | t
55 | 55 | x | t
56 | 56 | x | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------
Limit (cost=3.33..3.44 rows=5 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=3.33..3.44 rows=5 width=14)
Merge Key: public.pt_lt_tab_df.col2, public.pt_lt_tab_df.col3
-> Limit (cost=3.33..3.34 rows=2 width=14)
-> Sort (cost=3.33..3.35 rows=4 width=14)
Sort Key: public.pt_lt_tab_df.col2, public.pt_lt_tab_df.col3
-> Append (cost=0.00..3.16 rows=4 width=14)
-> Seq Scan on pt_lt_tab_df_1_prt_def pt_lt_tab_df (cost=0.00..3.16 rows=4 width=14)
Filter: col2 > 51::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off
Optimizer status: legacy query optimizer
(11 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
50 | 50 | q | f
(1 row)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=1103.54..1103.59 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=1103.54..1103.59 rows=2 width=14)
Merge Key: public.pt_lt_tab_df.col3
-> Limit (cost=1103.54..1103.55 rows=1 width=14)
-> Sort (cost=1103.54..1103.55 rows=1 width=14)
Sort Key: public.pt_lt_tab_df.col3
-> Append (cost=0.00..1103.53 rows=1 width=14)
-> Index Scan using idx5 on pt_lt_tab_df_1_prt_part5 pt_lt_tab_df (cost=0.00..1100.37 rows=1 width=14)
Index Cond: col2 = 50::numeric
-> Seq Scan on pt_lt_tab_df_1_prt_def pt_lt_tab_df (cost=0.00..3.16 rows=1 width=14)
Filter: col2 = 50::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off
Optimizer status: legacy query optimizer
(13 rows)
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
-- @description Negative tests Combination tests ,index exists on some regular partitions and not on the default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 is NULL ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
| | |
| | |
| | |
(3 rows)
DROP INDEX idx1;
DROP INDEX idx5;
-- @description Heterogeneous index,b-tree index on all parts,index , multiple index
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2,col1);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2,col1);
......@@ -1519,6 +1593,82 @@ DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
DROP INDEX idx6;
-- @description Index exists on some continuous set of partitions, e.g. p1,p2,p3
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
35 | 35 | o | f
(1 row)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------
Limit (cost=6.30..6.34 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=6.30..6.34 rows=2 width=14)
Merge Key: public.pt_lt_tab_df.col3
-> Limit (cost=6.30..6.30 rows=1 width=14)
-> Sort (cost=6.30..6.30 rows=1 width=14)
Sort Key: public.pt_lt_tab_df.col3
-> Append (cost=0.00..6.29 rows=1 width=14)
-> Seq Scan on pt_lt_tab_df_1_prt_part4 pt_lt_tab_df (cost=0.00..3.12 rows=1 width=14)
Filter: col2 = 35::numeric
-> Seq Scan on pt_lt_tab_df_1_prt_def pt_lt_tab_df (cost=0.00..3.16 rows=1 width=14)
Filter: col2 = 35::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off
Optimizer status: legacy query optimizer
(13 rows)
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
-- @description Index exists on some regular partitions and on the default partition [INDEX exists on non-consecutive partitions, e.g. p1,p3,p5]
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
CREATE INDEX idx6 on pt_lt_tab_df_1_prt_def(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
16 | 16 | f | t
17 | 17 | g | t
18 | 18 | g | t
19 | 19 | g | t
20 | 20 | g | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=17717.24..17717.35 rows=5 width=15)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=17717.24..17717.35 rows=5 width=15)
Merge Key: public.pt_lt_tab_df.col2, public.pt_lt_tab_df.col3
-> Limit (cost=17717.24..17717.25 rows=2 width=15)
-> Sort (cost=17717.24..17717.35 rows=16 width=15)
Sort Key: public.pt_lt_tab_df.col2, public.pt_lt_tab_df.col3
-> Append (cost=0.00..17716.48 rows=16 width=15)
-> Seq Scan on pt_lt_tab_df_1_prt_part2 pt_lt_tab_df (cost=0.00..3.12 rows=2 width=14)
Filter: col2 > 15::numeric
-> Seq Scan on pt_lt_tab_df_1_prt_part3 pt_lt_tab_df (cost=0.00..3.12 rows=4 width=14)
Filter: col2 > 15::numeric
-> Seq Scan on pt_lt_tab_df_1_prt_part4 pt_lt_tab_df (cost=0.00..3.12 rows=4 width=14)
Filter: col2 > 15::numeric
-> Bitmap Heap Scan on pt_lt_tab_df_1_prt_part5 pt_lt_tab_df (cost=10000.43..10003.55 rows=4 width=14)
Recheck Cond: col2 > 15::numeric
-> Bitmap Index Scan on idx5 (cost=0.00..10000.43 rows=4 width=0)
Index Cond: col2 > 15::numeric
-> Bitmap Heap Scan on pt_lt_tab_df_1_prt_def pt_lt_tab_df (cost=7700.43..7703.55 rows=4 width=14)
Recheck Cond: col2 > 15::numeric
-> Bitmap Index Scan on idx6 (cost=0.00..7700.43 rows=4 width=0)
Index Cond: col2 > 15::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off
Optimizer status: legacy query optimizer
(23 rows)
DROP INDEX idx1;
DROP INDEX idx5;
DROP INDEX idx6;
--
-- See MPP-6861
--
......
......@@ -1072,6 +1072,83 @@ DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
DROP INDEX idx6;
-- @description Negative tests Combination tests, no index on default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
CREATE INDEX idx4 on pt_lt_tab_df_1_prt_part4(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
52 | 52 | u | t
53 | 53 | u | t
54 | 54 | x | t
55 | 55 | x | t
56 | 56 | x | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.00 rows=2 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..431.00 rows=2 width=14)
-> Sort (cost=0.00..431.00 rows=3 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.00 rows=3 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=34 width=4)
Filter: col2 > 51::numeric
Partitions selected: 1 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=3 width=14)
Filter: col2 > 51::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.7.0
(14 rows)
SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
50 | 50 | q | f
(1 row)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.00 rows=1 width=14)
-> Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=14)
Merge Key: col2, col3
-> Sort (cost=0.00..431.00 rows=1 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.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 = 50::numeric
Partitions selected: 1 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=1 width=14)
Filter: col2 = 50::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.7.0
(13 rows)
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
-- @description Negative tests Combination tests ,index exists on some regular partitions and not on the default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 is NULL ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
| | |
| | |
| | |
(3 rows)
DROP INDEX idx1;
DROP INDEX idx5;
-- @description Heterogeneous index,b-tree index on all parts,index , multiple index
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2,col1);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2,col1);
......@@ -1161,6 +1238,73 @@ DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
DROP INDEX idx6;
-- @description Index exists on some continuous set of partitions, e.g. p1,p2,p3
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
35 | 35 | o | f
(1 row)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.00 rows=1 width=14)
-> Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..431.00 rows=1 width=14)
Merge Key: col2, col3
-> Sort (cost=0.00..431.00 rows=1 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.00 rows=1 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=50 width=4)
Filter: col2 = 35::numeric
Partitions selected: 1 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=1 width=14)
Filter: col2 = 35::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.7.0
(13 rows)
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
-- @description Index exists on some regular partitions and on the default partition [INDEX exists on non-consecutive partitions, e.g. p1,p3,p5]
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
CREATE INDEX idx6 on pt_lt_tab_df_1_prt_def(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
16 | 16 | f | t
17 | 17 | g | t
18 | 18 | g | t
19 | 19 | g | t
20 | 20 | g | t
(5 rows)
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..431.01 rows=3 width=14)
-> Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..431.01 rows=5 width=14)
Merge Key: col2, col3
-> Limit (cost=0.00..431.01 rows=3 width=14)
-> Sort (cost=0.00..431.01 rows=23 width=14)
Sort Key: col2, col3
-> Sequence (cost=0.00..431.00 rows=23 width=14)
-> Partition Selector for pt_lt_tab_df (dynamic scan id: 1) (cost=10.00..100.00 rows=50 width=4)
Filter: col2 > 15::numeric
Partitions selected: 5 (out of 6)
-> Dynamic Table Scan on pt_lt_tab_df (dynamic scan id: 1) (cost=0.00..431.00 rows=23 width=14)
Filter: col2 > 15::numeric
Settings: enable_bitmapscan=on; enable_indexscan=on; enable_seqscan=off; optimizer=on
Optimizer status: PQO version 2.7.0
(14 rows)
DROP INDEX idx1;
DROP INDEX idx5;
DROP INDEX idx6;
--
-- See MPP-6861
--
......
......@@ -251,6 +251,34 @@ DROP INDEX idx5;
DROP INDEX idx6;
-- @description Negative tests Combination tests, no index on default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
CREATE INDEX idx4 on pt_lt_tab_df_1_prt_part4(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
DROP INDEX idx4;
DROP INDEX idx5;
-- @description Negative tests Combination tests ,index exists on some regular partitions and not on the default partition
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 is NULL ORDER BY col2,col3 LIMIT 5;
DROP INDEX idx1;
DROP INDEX idx5;
-- @description Heterogeneous index,b-tree index on all parts,index , multiple index
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2,col1);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2,col1);
......@@ -274,6 +302,32 @@ DROP INDEX idx5;
DROP INDEX idx6;
-- @description Index exists on some continuous set of partitions, e.g. p1,p2,p3
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_df_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_df_1_prt_part3(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
DROP INDEX idx1;
DROP INDEX idx2;
DROP INDEX idx3;
-- @description Index exists on some regular partitions and on the default partition [INDEX exists on non-consecutive partitions, e.g. p1,p3,p5]
CREATE INDEX idx1 on pt_lt_tab_df_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_df_1_prt_part5(col2);
CREATE INDEX idx6 on pt_lt_tab_df_1_prt_def(col2);
SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
EXPLAIN SELECT * FROM pt_lt_tab_df WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
DROP INDEX idx1;
DROP INDEX idx5;
DROP INDEX idx6;
--
-- See MPP-6861
--
......
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description Negative tests combination tests, Index exists on some continuous set of partitions, e.g. p1,p2,p3
SELECT * FROM pt_lt_tab WHERE col2 = 35 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
35 | 35 | part4 | f
(1 row)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description Negative tests Combination tests , no index on default partition
SELECT * FROM pt_lt_tab WHERE col2 > 51 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
52 | 52 | def | f
53 | 53 | def | f
54 | 54 | def | f
55 | 55 | def | f
56 | 56 | def | f
(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 Negative tests Combination tests , no index on default partition
SELECT * FROM pt_lt_tab WHERE col2 = 50 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
50 | 50 | part5 | f
(1 row)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @description Negative tests Combination tests ,index exists on some regular partitions and not on the default partition
SELECT * FROM pt_lt_tab WHERE col2 is NULL ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+------+------
| | |
(1 row)
-- @author prabhd
-- @modified 2013-08-01 12:00:00
-- @created 2013-08-01 12:00:00
-- @db_name ptidx
-- @tags partitionindexes
-- @negtest True
-- @ description Negative tests Combination tests, Index exists on some regular partitions and on the default partition [INDEX exists on non-consecutive partitions, e.g. p1,p3,p5]
SELECT * FROM pt_lt_tab WHERE col2 > 15 ORDER BY col2,col3 LIMIT 5;
col1 | col2 | col3 | col4
------+------+-------+------
16 | 16 | part2 | t
17 | 17 | part2 | t
18 | 18 | part2 | t
19 | 19 | part2 | t
20 | 20 | 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 Negative tests combination tests, Index exists on some continuous set of partitions, e.g. p1,p2,p3
SELECT * FROM pt_lt_tab WHERE col2 = 35 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,'def',False FROM generate_series(51,100)i;
INSERT INTO pt_lt_tab VALUES(NULL,NULL,NULL,NULL);
DROP INDEX IF EXISTS idx1;
DROP INDEX IF EXISTS idx2;
DROP INDEX IF EXISTS idx3;
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_1_prt_part3(col2);
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 Negative tests Combination tests , no index on default partition
SELECT * FROM pt_lt_tab WHERE col2 > 51 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,'def',False FROM generate_series(51,100)i;
INSERT INTO pt_lt_tab VALUES(NULL,NULL,NULL,NULL);
DROP INDEX IF EXISTS idx1;
DROP INDEX IF EXISTS idx2;
DROP INDEX IF EXISTS idx3;
DROP INDEX IF EXISTS idx4;
DROP INDEX IF EXISTS idx5;
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_1_prt_part3(col2);
CREATE INDEX idx4 on pt_lt_tab_1_prt_part4(col2);
CREATE INDEX idx5 on pt_lt_tab_1_prt_part5(col2);
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 Negative tests Combination tests , no index on default partition
SELECT * FROM pt_lt_tab WHERE col2 = 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,'def',False FROM generate_series(51,100)i;
INSERT INTO pt_lt_tab VALUES(NULL,NULL,NULL,NULL);
DROP INDEX IF EXISTS idx1;
DROP INDEX IF EXISTS idx2;
DROP INDEX IF EXISTS idx3;
DROP INDEX IF EXISTS idx4;
DROP INDEX IF EXISTS idx5;
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx2 on pt_lt_tab_1_prt_part2(col2);
CREATE INDEX idx3 on pt_lt_tab_1_prt_part3(col2);
CREATE INDEX idx4 on pt_lt_tab_1_prt_part4(col2);
CREATE INDEX idx5 on pt_lt_tab_1_prt_part5(col2);
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 Negative tests Combination tests ,index exists on some regular partitions and not on the default partition
SELECT * FROM pt_lt_tab WHERE col2 is NULL 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,'def',False FROM generate_series(51,100)i;
INSERT INTO pt_lt_tab VALUES(NULL,NULL,NULL,NULL);
DROP INDEX IF EXISTS idx1;
DROP INDEX IF EXISTS idx5;
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_1_prt_part5(col2);
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 Negative tests Combination tests, Index exists on some regular partitions and on the default partition [INDEX exists on non-consecutive partitions, e.g. p1,p3,p5]
SELECT * FROM pt_lt_tab WHERE col2 > 15 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,'def',False FROM generate_series(51,100)i;
INSERT INTO pt_lt_tab VALUES(NULL,NULL,NULL,NULL);
DROP INDEX IF EXISTS idx1;
DROP INDEX IF EXISTS idx5;
DROP INDEX IF EXISTS idx6;
CREATE INDEX idx1 on pt_lt_tab_1_prt_part1(col2);
CREATE INDEX idx5 on pt_lt_tab_1_prt_part5(col2);
CREATE INDEX idx6 on pt_lt_tab_1_prt_def(col2);
ANALYZE pt_lt_tab;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册