diff --git a/src/common/backend/utils/adt/selfuncs.cpp b/src/common/backend/utils/adt/selfuncs.cpp index b2a63bce..205d2291 100644 --- a/src/common/backend/utils/adt/selfuncs.cpp +++ b/src/common/backend/utils/adt/selfuncs.cpp @@ -6518,7 +6518,8 @@ static void genericcostestimate(PlannerInfo* root, IndexPath* path, double loop_ * enough to not alter index-vs-seqscan decisions, but will prevent * indexes of different sizes from looking exactly equally attractive. */ - *indexTotalCost += index->pages * spc_random_page_cost / 100000.0; + if (ENABLE_SQL_BETA_FEATURE(INDEX_COST_WITH_LEAF_PAGES_ONLY)) + *indexTotalCost += index->pages * spc_random_page_cost / 100000.0; /* * CPU cost: any complex expressions in the indexquals will need to be diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index 0df24d6a..56602ddd 100644 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -995,6 +995,8 @@ static const struct config_enum_entry sql_beta_options[] = { {"param_path_opt", PARAM_PATH_OPT, false}, {"no_unique_index_first", NO_UNIQUE_INDEX_FIRST, false}, {"join_sel_with_cast_func", JOIN_SEL_WITH_CAST_FUNC, false}, + {"canonical_pathkey", CANONICAL_PATHKEY, false}, + {"index_cost_with_leaf_pages_only", INDEX_COST_WITH_LEAF_PAGES_ONLY, false}, {NULL, 0, false} }; diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index eee2cb01..071d7eec 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -358,7 +358,9 @@ typedef enum { PARAM_PATH_OPT = 16, /* Parametrized Path Optimization. */ PAGE_EST_OPT = 32, /* More accurate (rowstored) index pages estimation */ NO_UNIQUE_INDEX_FIRST = 64, /* use unique index first rule in path generation */ - JOIN_SEL_WITH_CAST_FUNC = 128 /* support cast function while calculating join selectivity */ + JOIN_SEL_WITH_CAST_FUNC = 128, /* support cast function while calculating join selectivity */ + CANONICAL_PATHKEY = 256, /* Use canonicalize pathkeys directly */ + INDEX_COST_WITH_LEAF_PAGES_ONLY = 512 /* compute index cost with consideration of leaf-pages-only */ } sql_beta_param; #define ENABLE_PRED_PUSH(root) \ diff --git a/src/test/regress/expected/bypass_preparedexecute_support.out b/src/test/regress/expected/bypass_preparedexecute_support.out index a4e9e3b7..371f098e 100644 --- a/src/test/regress/expected/bypass_preparedexecute_support.out +++ b/src/test/regress/expected/bypass_preparedexecute_support.out @@ -7,6 +7,7 @@ set enable_seqscan=off; set opfusion_debug_mode = 'log'; set log_min_messages=debug; set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; drop table if exists test_bypass_sq1; NOTICE: table "test_bypass_sq1" does not exist, skipping create table test_bypass_sq1(col1 int, col2 int, col3 text); diff --git a/src/test/regress/expected/bypass_simplequery_support.out b/src/test/regress/expected/bypass_simplequery_support.out index 8a5b0771..50203eb9 100644 --- a/src/test/regress/expected/bypass_simplequery_support.out +++ b/src/test/regress/expected/bypass_simplequery_support.out @@ -7,6 +7,7 @@ set enable_seqscan=off; set opfusion_debug_mode = 'log'; set log_min_messages=debug; set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; -- create table drop table if exists test_bypass_sq1; NOTICE: table "test_bypass_sq1" does not exist, skipping diff --git a/src/test/regress/expected/gpi_build_index.out b/src/test/regress/expected/gpi_build_index.out index 1ecb1867..509d1ec7 100644 --- a/src/test/regress/expected/gpi_build_index.out +++ b/src/test/regress/expected/gpi_build_index.out @@ -227,11 +227,11 @@ Number of partition: 5 (View pg_partition to check each partition range.) insert into test_gpi_create_like values(generate_series(0,9999), 1); explain (costs off) select * from test_gpi_create_like where c1 = 0; - QUERY PLAN ------------------------------------------------------------------ + QUERY PLAN +-------------------------------------------------------------------- Bitmap Heap Scan on test_gpi_create_like Recheck Cond: (c1 = 0) - -> Bitmap Index Scan on test_gpi_create_like_c1_tableoid_idx + -> Bitmap Index Scan on test_gpi_create_like_c1_c2_tableoid_idx Index Cond: (c1 = 0) (4 rows) diff --git a/src/test/regress/expected/gpi_clean_wait.out b/src/test/regress/expected/gpi_clean_wait.out index 93e775ee..a7ac796a 100644 --- a/src/test/regress/expected/gpi_clean_wait.out +++ b/src/test/regress/expected/gpi_clean_wait.out @@ -21,9 +21,9 @@ select a.relname,a.parttype,a.reloptions from pg_partition a, pg_class b where a (2 rows) explain (costs off) select * from test_gpi_more_invalid where a >= 3000; - QUERY PLAN ---------------------------------------------------------------------------- - Index Scan using global_index_gpi_more_invalid_b on test_gpi_more_invalid + QUERY PLAN +------------------------------------------------------------------------------------ + Index Only Scan using global_index_gpi_more_invalid_a_b_c on test_gpi_more_invalid Index Cond: (a >= 3000) (2 rows) @@ -55,10 +55,10 @@ explain (costs off) select count(*) from test_gpi_more_invalid where a <= 100 an (4 rows) explain (costs off) select count(*) from test_gpi_more_invalid where a > 3000; - QUERY PLAN --------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------ Aggregate - -> Index Only Scan using global_index_gpi_more_invalid_b on test_gpi_more_invalid + -> Index Only Scan using global_index_gpi_more_invalid_a_b_c on test_gpi_more_invalid Index Cond: (a > 3000) (3 rows) diff --git a/src/test/regress/expected/gpi_index.out b/src/test/regress/expected/gpi_index.out index da2967b9..a16c2607 100644 --- a/src/test/regress/expected/gpi_index.out +++ b/src/test/regress/expected/gpi_index.out @@ -119,12 +119,11 @@ select * from gpi_index_test where a < 200 and b > 190 order by a; -- multi column index with global index create index gpi_index_test_global_a_b on gpi_index_test(a,b) global; explain (costs off) select * from gpi_index_test where a = 200 and b = 100; - QUERY PLAN ------------------------------------------------------------- - Index Scan using gpi_index_test_global_b on gpi_index_test - Index Cond: (b = 100) - Filter: (a = 200) -(3 rows) + QUERY PLAN +-------------------------------------------------------------- + Index Scan using gpi_index_test_global_a_b on gpi_index_test + Index Cond: ((a = 200) AND (b = 100)) +(2 rows) select * from gpi_index_test where a = 100 and b = 100 order by a; a | b | c diff --git a/src/test/regress/expected/sqlbypass_partition.out b/src/test/regress/expected/sqlbypass_partition.out index 3377a275..1cf996d1 100644 --- a/src/test/regress/expected/sqlbypass_partition.out +++ b/src/test/regress/expected/sqlbypass_partition.out @@ -1,28 +1,29 @@ -set enable_opfusion=on; -set enable_partition_opfusion=on; -set enable_bitmapscan=off; -set enable_seqscan=off; -set opfusion_debug_mode = 'log'; -set log_min_messages=debug; -set logging_module = 'on(OPFUSION)'; ---create table -drop table if exists test_bypass_sql_partition; +set enable_opfusion=on; +set enable_partition_opfusion=on; +set enable_bitmapscan=off; +set enable_seqscan=off; +set opfusion_debug_mode = 'log'; +set log_min_messages=debug; +set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; +--create table +drop table if exists test_bypass_sql_partition; NOTICE: table "test_bypass_sql_partition" does not exist, skipping -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; ---insert -explain insert into test_bypass_sql_partition values (0,0,'test_insert'); +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +--insert +explain insert into test_bypass_sql_partition values (0,0,'test_insert'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -30,8 +31,8 @@ explain insert into test_bypass_sql_partition values (0,0,'test_insert'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (0,0,'test_insert'); -explain insert into test_bypass_sql_partition values (0,1,'test_insert'); +insert into test_bypass_sql_partition values (0,0,'test_insert'); +explain insert into test_bypass_sql_partition values (0,1,'test_insert'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -39,8 +40,8 @@ explain insert into test_bypass_sql_partition values (0,1,'test_insert'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (0,1,'test_insert'); -explain insert into test_bypass_sql_partition values (11,1,'test_insert'); +insert into test_bypass_sql_partition values (0,1,'test_insert'); +explain insert into test_bypass_sql_partition values (11,1,'test_insert'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -48,8 +49,8 @@ explain insert into test_bypass_sql_partition values (11,1,'test_insert'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (11,1,'test_insert'); -explain insert into test_bypass_sql_partition values (11,2,'test_insert'); +insert into test_bypass_sql_partition values (11,1,'test_insert'); +explain insert into test_bypass_sql_partition values (11,2,'test_insert'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -57,8 +58,8 @@ explain insert into test_bypass_sql_partition values (11,2,'test_insert'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (11,2,'test_insert'); -explain insert into test_bypass_sql_partition values (0,10,'test_insert2'); +insert into test_bypass_sql_partition values (11,2,'test_insert'); +explain insert into test_bypass_sql_partition values (0,10,'test_insert2'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -66,8 +67,8 @@ explain insert into test_bypass_sql_partition values (0,10,'test_insert2'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (0,10,'test_insert2'); -explain insert into test_bypass_sql_partition values (2,12,'test_insert2'); +insert into test_bypass_sql_partition values (0,10,'test_insert2'); +explain insert into test_bypass_sql_partition values (2,12,'test_insert2'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -75,8 +76,8 @@ explain insert into test_bypass_sql_partition values (2,12,'test_insert2'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (2,12,'test_insert2'); -explain insert into test_bypass_sql_partition values (30,0,'test_insert3'); +insert into test_bypass_sql_partition values (2,12,'test_insert2'); +explain insert into test_bypass_sql_partition values (30,0,'test_insert3'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -84,8 +85,8 @@ explain insert into test_bypass_sql_partition values (30,0,'test_insert3'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (30,0,'test_insert3'); -explain insert into test_bypass_sql_partition values (3,3,'test_insert3'); +insert into test_bypass_sql_partition values (30,0,'test_insert3'); +explain insert into test_bypass_sql_partition values (3,3,'test_insert3'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -93,8 +94,8 @@ explain insert into test_bypass_sql_partition values (3,3,'test_insert3'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (3,3,'test_insert3'); -explain insert into test_bypass_sql_partition(col1,col2) values (1,1); +insert into test_bypass_sql_partition values (3,3,'test_insert3'); +explain insert into test_bypass_sql_partition(col1,col2) values (1,1); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -102,8 +103,8 @@ explain insert into test_bypass_sql_partition(col1,col2) values (1,1); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition(col1,col2) values (1,1); -explain insert into test_bypass_sql_partition(col1,col2) values (22,2); +insert into test_bypass_sql_partition(col1,col2) values (1,1); +explain insert into test_bypass_sql_partition(col1,col2) values (22,2); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -111,8 +112,8 @@ explain insert into test_bypass_sql_partition(col1,col2) values (22,2); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition(col1,col2) values (22,2); -explain insert into test_bypass_sql_partition(col1,col2) values (33,3); +insert into test_bypass_sql_partition(col1,col2) values (22,2); +explain insert into test_bypass_sql_partition(col1,col2) values (33,3); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -120,9 +121,9 @@ explain insert into test_bypass_sql_partition(col1,col2) values (33,3); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition(col1,col2) values (33,3); ---error -explain insert into test_bypass_sql_partition values (null,null,null); +insert into test_bypass_sql_partition(col1,col2) values (33,3); +--error +explain insert into test_bypass_sql_partition values (null,null,null); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -130,10 +131,10 @@ explain insert into test_bypass_sql_partition values (null,null,null); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (null,null,null); +insert into test_bypass_sql_partition values (null,null,null); ERROR: inserted partition key does not map to any table partition ---nobypass -explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +--nobypass +explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); QUERY PLAN ---------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because the expression of query is not support. @@ -141,26 +142,26 @@ explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'t -> Result (cost=0.00..5.01 rows=1000 width=0) (3 rows) -insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); ---select -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); ---bypass -set enable_indexonlyscan=off; -explain select * from test_bypass_sql_partition where col1=0 and col2=0; +insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +--select +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); +--bypass +set enable_indexonlyscan=off; +explain select * from test_bypass_sql_partition where col1=0 and col2=0; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -171,13 +172,13 @@ explain select * from test_bypass_sql_partition where col1=0 and col2=0; Selected Partitions: 1 (6 rows) -select * from test_bypass_sql_partition where col1=0 and col2=0; +select * from test_bypass_sql_partition where col1=0 and col2=0; col1 | col2 | col3 ------+------+--------- 0 | 0 | aaaaaaa (1 row) -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -188,7 +189,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<2 Selected Partitions: 2 (6 rows) -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; col1 | col2 ------+------ 11 | 10 @@ -211,7 +212,7 @@ select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and co 19 | 20 (18 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -223,13 +224,13 @@ explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<2 Selected Partitions: 2 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; col1 | col2 ------+------ 11 | 10 (1 row) -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -242,13 +243,13 @@ explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<2 Selected Partitions: 2 (8 rows) -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; col1 | col2 ------+------ 11 | 10 (1 row) -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -260,12 +261,12 @@ explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<2 Selected Partitions: 2 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; col1 | col2 ------+------ (0 rows) -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -278,13 +279,12 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 Selected Partitions: 2 (8 rows) -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; col1 | col2 ------+------ (0 rows) - -explain select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; +explain select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -295,7 +295,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1 is not null a Selected Partitions: 1..8 (6 rows) -select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; +select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; col1 | col2 ------+------ 0 | 0 @@ -1180,7 +1180,7 @@ select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 79 | 100 (880 rows) -explain select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; +explain select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1191,7 +1191,7 @@ explain select * from test_bypass_sql_partition where col1 is not null and col2 Selected Partitions: 1..8 (6 rows) -select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; +select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; col1 | col2 | col3 ------+------+--------- 0 | 0 | aaaaaaa @@ -1276,7 +1276,7 @@ select * from test_bypass_sql_partition where col1 is not null and col2 = 0 orde 79 | 0 | aaaaaaa (80 rows) -explain select * from test_bypass_sql_partition where col1=0 and col2=-1; +explain select * from test_bypass_sql_partition where col1=0 and col2=-1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1287,15 +1287,15 @@ explain select * from test_bypass_sql_partition where col1=0 and col2=-1; Selected Partitions: 1 (6 rows) -select * from test_bypass_sql_partition where col1=0 and col2=-1; +select * from test_bypass_sql_partition where col1=0 and col2=-1; col1 | col2 | col3 ------+------+------ (0 rows) -reset enable_indexonlyscan; ---bypass though index only scan -set enable_indexscan = off; -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; +reset enable_indexonlyscan; +--bypass though index only scan +set enable_indexscan = off; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1306,13 +1306,13 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1 Selected Partitions: 2 (6 rows) -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; col1 | col2 ------+------ 10 | 10 (1 row) -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1324,13 +1324,13 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1 Selected Partitions: 2 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; col1 | col2 ------+------ 10 | 10 (1 row) -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1342,14 +1342,14 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1 Selected Partitions: 2 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; col1 | col2 ------+------ (0 rows) -reset enable_indexscan; ---error -explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; +reset enable_indexscan; +--error +explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit count grammar with const less than zero. @@ -1361,9 +1361,9 @@ explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by Selected Partitions: 1 (7 rows) -select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; +select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; ERROR: LIMIT must not be negative -explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; +explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit count grammar with const less than zero. @@ -1376,10 +1376,10 @@ explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by Selected Partitions: 1 (8 rows) -select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; +select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; ERROR: LIMIT must not be negative ---nobypass -explain select * from test_bypass_sql_partition where col1 is null and col2 is null; +--nobypass +explain select * from test_bypass_sql_partition where col1 is null and col2 is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in zero partition. @@ -1390,12 +1390,12 @@ explain select * from test_bypass_sql_partition where col1 is null and col2 is n Selected Partitions: NONE (6 rows) -select * from test_bypass_sql_partition where col1 is null and col2 is null; +select * from test_bypass_sql_partition where col1 is null and col2 is null; col1 | col2 | col3 ------+------+------ (0 rows) -select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; col1 | col2 ------+------ 10 | 0 @@ -1410,7 +1410,7 @@ select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 10 | 90 (10 rows) -explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1422,7 +1422,7 @@ explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and co Selected Partitions: 2..4 (7 rows) -select col1, col2 from test_bypass_sql_partition order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition order by col1 limit 10; col1 | col2 ------+------ 0 | 0 @@ -1437,7 +1437,7 @@ select col1, col2 from test_bypass_sql_partition order by col1 limit 10; 0 | 90 (10 rows) -explain select col1, col2 from test_bypass_sql_partition order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition order by col1 limit 10; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1448,7 +1448,7 @@ explain select col1, col2 from test_bypass_sql_partition order by col1 limit 10; Selected Partitions: 1..8 (6 rows) -select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; col1 | col2 ------+------ 1 | 0 @@ -1463,7 +1463,7 @@ select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 li 1 | 90 (10 rows) -explain select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1475,7 +1475,7 @@ explain select col1, col2 from test_bypass_sql_partition where col1 > 0 order by Selected Partitions: 1..8 (7 rows) -select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; col1 | col2 ------+------ 0 | 0 @@ -1490,7 +1490,7 @@ select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 l 0 | 90 (10 rows) -explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1502,11 +1502,9 @@ explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order b Selected Partitions: 1..2 (7 rows) - ---update ---bypass - -explain update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=0 and col2=0; +--update +--bypass +explain update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=0 and col2=0; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1518,8 +1516,8 @@ explain update test_bypass_sql_partition set col2=col2-1,col3='test_update' wher Selected Partitions: 1 (7 rows) -update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=10 and col2=0; -explain update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; +update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=10 and col2=0; +explain update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1531,8 +1529,8 @@ explain update test_bypass_sql_partition set col2=col1-1,col3='test_update' wher Selected Partitions: 3 (7 rows) -update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; -explain update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; +update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; +explain update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1544,9 +1542,9 @@ explain update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col Selected Partitions: 1 (7 rows) -update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; ---not bypass -explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; +--not bypass +explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); QUERY PLAN ---------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because the expression of query is not support. @@ -1554,7 +1552,7 @@ explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'t -> Result (cost=0.00..5.01 rows=1000 width=0) (3 rows) -explain select * from test_bypass_sql_partition where col3 is not null; +explain select * from test_bypass_sql_partition where col3 is not null; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -1565,7 +1563,7 @@ explain select * from test_bypass_sql_partition where col3 is not null; Selected Partitions: 1..8 (6 rows) -explain update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; +explain update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in zero partition. @@ -1577,11 +1575,9 @@ explain update test_bypass_sql_partition set col3='test_null' where col1 is null Selected Partitions: NONE (7 rows) -update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; - - ---bypass -explain update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; +update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; +--bypass +explain update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1593,8 +1589,8 @@ explain update test_bypass_sql_partition set col2=111,col3='test_update2' where Selected Partitions: 1 (7 rows) -update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; -explain select * from test_bypass_sql_partition where col1=0 order by col1; +update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; +explain select * from test_bypass_sql_partition where col1=0 order by col1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1605,7 +1601,7 @@ explain select * from test_bypass_sql_partition where col1=0 order by col1; Selected Partitions: 1 (6 rows) -select * from test_bypass_sql_partition where col1=0 order by col1; +select * from test_bypass_sql_partition where col1=0 order by col1; col1 | col2 | col3 ------+------+-------------- 0 | 111 | test_update2 @@ -1621,7 +1617,7 @@ select * from test_bypass_sql_partition where col1=0 order by col1; 0 | 111 | test_update2 (11 rows) -explain select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; +explain select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1634,14 +1630,14 @@ explain select * from test_bypass_sql_partition where col1=0 order by col1 for u Selected Partitions: 1 (8 rows) -select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; +select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; col1 | col2 | col3 ------+------+-------------- 0 | 111 | test_update2 0 | 111 | test_update2 (2 rows) -explain select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; +explain select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1654,15 +1650,14 @@ explain select * from test_bypass_sql_partition where col1=1 and col2=20 order b Selected Partitions: 1 (8 rows) -select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; +select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; col1 | col2 | col3 ------+------+--------- 1 | 20 | aaaaaaa (1 row) - ---nobypass -explain select * from test_bypass_sql_partition where col2=20 order by col1; +--nobypass +explain select * from test_bypass_sql_partition where col2=20 order by col1; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1673,7 +1668,7 @@ explain select * from test_bypass_sql_partition where col2=20 order by col1; Selected Partitions: 1..8 (6 rows) -select * from test_bypass_sql_partition where col2=20 order by col1; +select * from test_bypass_sql_partition where col2=20 order by col1; col1 | col2 | col3 ------+------+--------- 1 | 20 | aaaaaaa @@ -1757,7 +1752,7 @@ select * from test_bypass_sql_partition where col2=20 order by col1; 79 | 20 | aaaaaaa (79 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1769,7 +1764,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 order by co Selected Partitions: 1..8 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; col1 | col2 ------+------ 1 | 0 @@ -1784,7 +1779,7 @@ select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1 | 90 (10 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; +explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1796,7 +1791,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 order by co Selected Partitions: 1..8 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; +select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; col1 | col2 ------+------ 1 | 0 @@ -1804,7 +1799,7 @@ select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1 | 20 (3 rows) -explain select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1816,7 +1811,7 @@ explain select col1,col2 from test_bypass_sql_partition where col2<50 order by c Selected Partitions: 1..8 (7 rows) -select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; col1 | col2 ------+------ 1 | 0 @@ -1831,7 +1826,7 @@ select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limi 2 | 40 (10 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1843,7 +1838,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 Selected Partitions: 1..8 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; col1 | col2 ------+------ 0 | 111 @@ -1858,7 +1853,7 @@ select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order b 0 | 111 (10 rows) -explain select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; +explain select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -1870,7 +1865,7 @@ explain select * from test_bypass_sql_partition where col1>=0 and col2>0 order b Selected Partitions: 1..8 (7 rows) -select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; +select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; col1 | col2 | col3 ------+------+-------------- 0 | 111 | test_update2 @@ -1878,27 +1873,24 @@ select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 l 0 | 111 | test_update2 (3 rows) - - -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); - ---bypass though index only scan -set enable_indexscan = off; -explain select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); +--bypass though index only scan +set enable_indexscan = off; +explain select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1909,7 +1901,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1=0 order by c Selected Partitions: 1 (6 rows) -select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; +select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; col1 | col2 ------+------ 0 | 0 @@ -1925,7 +1917,7 @@ select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; 0 | 100 (11 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1937,7 +1929,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 Selected Partitions: 1 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; col1 | col2 ------+------ 1 | 0 @@ -1952,7 +1944,7 @@ select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order b 1 | 90 (10 rows) -explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; +explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1964,7 +1956,7 @@ explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 Selected Partitions: 1 (7 rows) -select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; +select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; col2 | col1 ------+------ 0 | 1 @@ -1972,7 +1964,7 @@ select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order b 20 | 1 (3 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1984,7 +1976,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<1 Selected Partitions: 1 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; col1 | col2 ------+------ 0 | 10 @@ -1992,7 +1984,7 @@ select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and co 0 | 30 (3 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2004,7 +1996,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<1 Selected Partitions: 1 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; col1 | col2 ------+------ 0 | 10 @@ -2109,8 +2101,8 @@ select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and co 9 | 100 (100 rows) ---nobypass -explain select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; +--nobypass +explain select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -2122,13 +2114,12 @@ explain select col2,col1 from test_bypass_sql_partition where col2=2 order by co Selected Partitions: 1..8 (7 rows) -select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; +select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; col2 | col1 ------+------ (0 rows) - -explain select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in zero partition. @@ -2140,13 +2131,12 @@ explain select col1,col2 from test_bypass_sql_partition where col1 is null and c Selected Partitions: NONE (7 rows) -select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; +select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; col1 | col2 ------+------ (0 rows) - -explain select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -2158,7 +2148,7 @@ explain select col1,col2 from test_bypass_sql_partition where col2<5 order by co Selected Partitions: 1..8 (7 rows) -select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; col1 | col2 ------+------ 0 | 0 @@ -2173,7 +2163,7 @@ select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 9 | 0 (10 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -2185,7 +2175,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<= Selected Partitions: 1..2 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; col1 | col2 ------+------ 0 | 10 @@ -2200,11 +2190,9 @@ select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and c 0 | 100 (10 rows) - -reset enable_indexscan; - ---nobypass -explain select * from test_bypass_sql_partition where col1>col2 limit 10; +reset enable_indexscan; +--nobypass +explain select * from test_bypass_sql_partition where col1>col2 limit 10; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -2216,7 +2204,7 @@ explain select * from test_bypass_sql_partition where col1>col2 limit 10; Selected Partitions: 1..8 (7 rows) -explain select * from test_bypass_sql_partition where col1=3 and col2=3 for update; +explain select * from test_bypass_sql_partition where col1=3 and col2=3 for update; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2228,12 +2216,12 @@ explain select * from test_bypass_sql_partition where col1=3 and col2=3 for upda Selected Partitions: 1 (7 rows) -select * from test_bypass_sql_partition where col1=3 and col2=3 for update; +select * from test_bypass_sql_partition where col1=3 and col2=3 for update; col1 | col2 | col3 ------+------+------ (0 rows) -explain select * from test_bypass_sql_partition where col3='test_update2'; +explain select * from test_bypass_sql_partition where col3='test_update2'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -2244,8 +2232,7 @@ explain select * from test_bypass_sql_partition where col3='test_update2'; Selected Partitions: 1..8 (6 rows) - -explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2257,7 +2244,7 @@ explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col Selected Partitions: 1 (7 rows) -select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; +select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; col1 | col2 | col3 ------+------+--------- 1 | 40 | aaaaaaa @@ -2265,7 +2252,7 @@ select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 orde 1 | 60 | aaaaaaa (3 rows) -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset 3; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2278,7 +2265,7 @@ explain select * from test_bypass_sql_partition where col1>0 and col1<10 order b Selected Partitions: 1 (8 rows) -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset null; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset null; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2291,7 +2278,7 @@ explain select * from test_bypass_sql_partition where col1>0 and col1<10 order b Selected Partitions: 1 (8 rows) -explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2303,7 +2290,7 @@ explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col Selected Partitions: 1 (7 rows) -select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; +select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; col1 | col2 | col3 ------+------+--------- 1 | 40 | aaaaaaa @@ -2395,7 +2382,7 @@ select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 orde 9 | 100 | aaaaaaa (87 rows) -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update offset 3; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2408,7 +2395,7 @@ explain select * from test_bypass_sql_partition where col1>0 and col1<10 order b Selected Partitions: 1 (8 rows) -explain update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; +explain update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2420,8 +2407,8 @@ explain update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; Selected Partitions: 1 (7 rows) -update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; -explain delete from test_bypass_sql_partition where col1=1 and col2=1; +update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; +explain delete from test_bypass_sql_partition where col1=1 and col2=1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2433,9 +2420,9 @@ explain delete from test_bypass_sql_partition where col1=1 and col2=1; Selected Partitions: 1 (7 rows) -delete from test_bypass_sql_partition where col1=1 and col2=1; ---error -explain delete from test_bypass_sql_partition where col1 is null and col2 is null; +delete from test_bypass_sql_partition where col1=1 and col2=1; +--error +explain delete from test_bypass_sql_partition where col1 is null and col2 is null; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in zero partition. @@ -2447,8 +2434,8 @@ explain delete from test_bypass_sql_partition where col1 is null and col2 is nul Selected Partitions: NONE (7 rows) -delete from test_bypass_sql_partition where col1 is null and col2 is null; -explain insert into test_bypass_sql_partition values (null,null,null); +delete from test_bypass_sql_partition where col1 is null and col2 is null; +explain insert into test_bypass_sql_partition values (null,null,null); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -2456,10 +2443,10 @@ explain insert into test_bypass_sql_partition values (null,null,null); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -insert into test_bypass_sql_partition values (null,null,null); +insert into test_bypass_sql_partition values (null,null,null); ERROR: inserted partition key does not map to any table partition ---bypass / set enable_bitmapscan=off; -select * from test_bypass_sql_partition where col1=3; +--bypass / set enable_bitmapscan=off; +select * from test_bypass_sql_partition where col1=3; col1 | col2 | col3 ------+------+--------- 3 | 0 | aaaaaaa @@ -2475,7 +2462,7 @@ select * from test_bypass_sql_partition where col1=3; 3 | 100 | aaaaaaa (11 rows) -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc; +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -2486,20 +2473,20 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 Selected Partitions: 1 (6 rows) -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10 desc; --order by is supported when ordered col is in index +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10 desc; --order by is supported when ordered col is in index ERROR: syntax error at or near "desc" LINE 1: ...tition where col1>0 and col1<10 order by col1 limit 10 desc; ^ -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; ERROR: syntax error at or near "order" LINE 1: ...s_sql_partition where col1>0 and col1<10 limit 10 order by c... ^ -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; ERROR: syntax error at or near "order" LINE 1: ...s_sql_partition where col1>0 and col1<10 limit 10 order by c... ^ ---not bypass -explain select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; +--not bypass +explain select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -2510,7 +2497,7 @@ explain select col1,col2 from test_bypass_sql_partition order by col1,col2 limit Selected Partitions: 1..8 (6 rows) -select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; +select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; col1 | col2 ------+------ 0 | 0 @@ -2525,7 +2512,7 @@ select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; 0 | 90 (10 rows) -explain select * from test_bypass_sql_partition where col1 > 0 order by col1,col2 desc limit 10; +explain select * from test_bypass_sql_partition where col1 > 0 order by col1,col2 desc limit 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -2539,8 +2526,8 @@ explain select * from test_bypass_sql_partition where col1 > 0 order by col1,col Selected Partitions: 1..8 (9 rows) ---bypass -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10 ; +--bypass +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -2552,7 +2539,7 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 Selected Partitions: 1 (7 rows) -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10; col1 | col2 ------+------ 1 | 0 @@ -2567,8 +2554,8 @@ select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order b 1 | 90 (10 rows) ---not bypass -explain select * from test_bypass_sql_partition where true; +--not bypass +explain select * from test_bypass_sql_partition where true; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -2578,7 +2565,7 @@ explain select * from test_bypass_sql_partition where true; Selected Partitions: 1..8 (5 rows) -explain select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -2589,7 +2576,7 @@ explain select col1, col2 from test_bypass_sql_partition where true order by col Selected Partitions: 1..8 (6 rows) -select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; col1 | col2 ------+------ 0 | 0 @@ -2604,9 +2591,8 @@ select col1, col2 from test_bypass_sql_partition where true order by col1 limit 0 | 90 (10 rows) ---bypass - -select col2, col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +--bypass +select col2, col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; col2 | col1 ------+------ 0 | 1 @@ -2621,7 +2607,7 @@ select col2, col1 from test_bypass_sql_partition where col1>0 and col1<10 order 90 | 1 (10 rows) -select col1, col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc limit 10; +select col1, col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc limit 10; col1 | col2 ------+------ 9 | 100 @@ -2636,7 +2622,7 @@ select col1, col2 from test_bypass_sql_partition where col1>0 and col1<10 order 9 | 10 (10 rows) -explain insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1=0; +explain insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1=0; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query combines insert operator with others. @@ -2648,15 +2634,12 @@ explain insert into test_bypass_sql_partition select * from test_bypass_sql_part Selected Partitions: 1 (7 rows) - -delete from test_bypass_sql_partition where col1=1; -delete from test_bypass_sql_partition where col1 > 10 and col1 < 0; -delete from test_bypass_sql_partition where col1 <= 11 and col1 >= 15; - ---nobypass -delete from test_bypass_sql_partition where col1 > 10; -delete from test_bypass_sql_partition where col1 < 10; -delete from test_bypass_sql_partition where col1 >= 10 and col1 <= 30; -reset enable_partition_opfusion; -drop table test_bypass_sql_partition; - +delete from test_bypass_sql_partition where col1=1; +delete from test_bypass_sql_partition where col1 > 10 and col1 < 0; +delete from test_bypass_sql_partition where col1 <= 11 and col1 >= 15; +--nobypass +delete from test_bypass_sql_partition where col1 > 10; +delete from test_bypass_sql_partition where col1 < 10; +delete from test_bypass_sql_partition where col1 >= 10 and col1 <= 30; +reset enable_partition_opfusion; +drop table test_bypass_sql_partition; diff --git a/src/test/regress/expected/sqlbypass_partition_prepare.out b/src/test/regress/expected/sqlbypass_partition_prepare.out index 88f5985a..62808383 100644 --- a/src/test/regress/expected/sqlbypass_partition_prepare.out +++ b/src/test/regress/expected/sqlbypass_partition_prepare.out @@ -1,33 +1,34 @@ -set enable_opfusion=on; -set enable_partition_opfusion=on; -set enable_bitmapscan=off; -set enable_seqscan=off; -set opfusion_debug_mode = 'log'; -set log_min_messages=debug; -set logging_module = 'on(OPFUSION)'; ---create table -drop table if exists test_bypass_sql_partition; +set enable_opfusion=on; +set enable_partition_opfusion=on; +set enable_bitmapscan=off; +set enable_seqscan=off; +set opfusion_debug_mode = 'log'; +set log_min_messages=debug; +set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; +--create table +drop table if exists test_bypass_sql_partition; NOTICE: table "test_bypass_sql_partition" does not exist, skipping -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( - partition test_bypass_sql_partition_1 values less than(10), - partition test_bypass_sql_partition_2 values less than(20), - partition test_bypass_sql_partition_3 values less than(30), - partition test_bypass_sql_partition_4 values less than(40), - partition test_bypass_sql_partition_5 values less than(50), - partition test_bypass_sql_partition_6 values less than(60), - partition test_bypass_sql_partition_7 values less than(70), - partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); -prepare p11 as insert into test_bypass_sql_partition values($1,$2,$3); -prepare p12 as insert into test_bypass_sql_partition(col1,col2) values ($1,$2); - - - -explain execute p11(0,0,'test_insert'); +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( + partition test_bypass_sql_partition_1 values less than(10), + partition test_bypass_sql_partition_2 values less than(20), + partition test_bypass_sql_partition_3 values less than(30), + partition test_bypass_sql_partition_4 values less than(40), + partition test_bypass_sql_partition_5 values less than(50), + partition test_bypass_sql_partition_6 values less than(60), + partition test_bypass_sql_partition_7 values less than(70), + partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); +prepare p11 as insert into test_bypass_sql_partition values($1,$2,$3); +prepare p12 as insert into test_bypass_sql_partition(col1,col2) values ($1,$2); + + + +explain execute p11(0,0,'test_insert'); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -35,13 +36,13 @@ explain execute p11(0,0,'test_insert'); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -execute p11(10,10,'test_insert'); -execute p11(12,12,'test_insert'); -execute p11(-1,-1,'test_insert2'); -execute p11(23,23,'test_insert2'); -execute p11(33,33,'test_insert3'); -execute p11(0,0,'test_insert3'); -explain execute p12(1,1); +execute p11(10,10,'test_insert'); +execute p11(12,12,'test_insert'); +execute p11(-1,-1,'test_insert2'); +execute p11(23,23,'test_insert2'); +execute p11(33,33,'test_insert3'); +execute p11(0,0,'test_insert3'); +explain execute p12(1,1); QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -49,18 +50,18 @@ explain execute p12(1,1); -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -execute p12(1,1); -execute p12(22,22); -execute p12(20,20); - ---nobypass -execute p11(null,null,null); +execute p12(1,1); +execute p12(22,22); +execute p12(20,20); + +--nobypass +execute p11(null,null,null); ERROR: inserted partition key does not map to any table partition -prepare p_insert1 as insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); -execute p_insert1; ---bypass -prepare p13 as select * from test_bypass_sql_partition where col1=$1 and col2=$2; -explain execute p13(0,0); +prepare p_insert1 as insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +execute p_insert1; +--bypass +prepare p13 as select * from test_bypass_sql_partition where col1=$1 and col2=$2; +explain execute p13(0,0); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -71,39 +72,39 @@ explain execute p13(0,0); Selected Partitions: PART (6 rows) -execute p13(0,0); +execute p13(0,0); col1 | col2 | col3 ------+------+-------------- 0 | 0 | test_insert3 0 | 0 | aaaaaaa (2 rows) -execute p13(10,0); +execute p13(10,0); col1 | col2 | col3 ------+------+--------- 10 | 0 | aaaaaaa (1 row) -execute p13(20,0); +execute p13(20,0); col1 | col2 | col3 ------+------+--------- 20 | 0 | aaaaaaa (1 row) -execute p13(30,0); +execute p13(30,0); col1 | col2 | col3 ------+------+--------- 30 | 0 | aaaaaaa (1 row) -execute p13(40,0); +execute p13(40,0); col1 | col2 | col3 ------+------+--------- 40 | 0 | aaaaaaa (1 row) -set enable_indexonlyscan=off; -explain execute p13(0,0); +set enable_indexonlyscan=off; +explain execute p13(0,0); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -114,16 +115,16 @@ explain execute p13(0,0); Selected Partitions: PART (6 rows) -execute p13(0,0); +execute p13(0,0); col1 | col2 | col3 ------+------+-------------- 0 | 0 | test_insert3 0 | 0 | aaaaaaa (2 rows) -reset enable_indexonlyscan; -prepare p15 as update test_bypass_sql_partition set col2=col2+$4,col3=$3 where col1=$1 and col2=$2; -explain execute p15 (0,0,'test_update',-1); +reset enable_indexonlyscan; +prepare p15 as update test_bypass_sql_partition set col2=col2+$4,col3=$3 where col1=$1 and col2=$2; +explain execute p15 (0,0,'test_update',-1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -135,9 +136,9 @@ explain execute p15 (0,0,'test_update',-1); Selected Partitions: PART (7 rows) -execute p15 (0,0,'test_update',-1); -prepare p16 as update test_bypass_sql_partition set col2=mod($1,$2) where col1=$3 and col2=$4; -explain execute p16(5,3,1,1); +execute p15 (0,0,'test_update',-1); +prepare p16 as update test_bypass_sql_partition set col2=mod($1,$2) where col1=$3 and col2=$4; +explain execute p16(5,3,1,1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -149,13 +150,13 @@ explain execute p16(5,3,1,1); Selected Partitions: PART (7 rows) -execute p16(5,3,1,1); - - -prepare p101 as update test_bypass_sql_partition set col2=$1,col3=$2 where col1=$3 ; -execute p101 (111,'test_update2',-1); -prepare p102 as select * from test_bypass_sql_partition where col1=$1; -execute p102 (1); +execute p16(5,3,1,1); + + +prepare p101 as update test_bypass_sql_partition set col2=$1,col3=$2 where col1=$3 ; +execute p101 (111,'test_update2',-1); +prepare p102 as select * from test_bypass_sql_partition where col1=$1; +execute p102 (1); col1 | col2 | col3 ------+------+--------- 1 | 0 | aaaaaaa @@ -172,14 +173,14 @@ execute p102 (1); 1 | 100 | aaaaaaa (12 rows) - - -prepare p1011 as insert into test_bypass_sql_partition values(-3,-3,'test_pbe'); -prepare p1013 as update test_bypass_sql_partition set col2=10 where col1=-3; -prepare p1012 as select * from test_bypass_sql_partition where col1=-3; -prepare p1014 as select * from test_bypass_sql_partition where col1=-3 for update; -prepare p1015 as delete from test_bypass_sql_partition where col1=-3; -explain execute p1011; + + +prepare p1011 as insert into test_bypass_sql_partition values(-3,-3,'test_pbe'); +prepare p1013 as update test_bypass_sql_partition set col2=10 where col1=-3; +prepare p1012 as select * from test_bypass_sql_partition where col1=-3; +prepare p1014 as select * from test_bypass_sql_partition where col1=-3 for update; +prepare p1015 as delete from test_bypass_sql_partition where col1=-3; +explain execute p1011; QUERY PLAN ----------------------------------------------------------------------- [Bypass] @@ -187,8 +188,8 @@ explain execute p1011; -> Result (cost=0.00..0.01 rows=1 width=0) (3 rows) -execute p1011; -explain execute p1012; +execute p1011; +explain execute p1012; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -199,13 +200,13 @@ explain execute p1012; Selected Partitions: 1 (6 rows) -execute p1012; +execute p1012; col1 | col2 | col3 ------+------+---------- -3 | -3 | test_pbe (1 row) -explain execute p1013; +explain execute p1013; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -217,8 +218,8 @@ explain execute p1013; Selected Partitions: 1 (7 rows) -execute p1013; -explain execute p1014; +execute p1013; +explain execute p1014; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -230,14 +231,14 @@ explain execute p1014; Selected Partitions: 1 (7 rows) -execute p1014; +execute p1014; col1 | col2 | col3 ------+------+---------- -3 | 10 | test_pbe (1 row) -prepare p10141 as select col1,col2 from test_bypass_sql_partition where col1=-3 for update; -explain execute p10141; +prepare p10141 as select col1,col2 from test_bypass_sql_partition where col1=-3 for update; +explain execute p10141; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -249,15 +250,15 @@ explain execute p10141; Selected Partitions: 1 (7 rows) -execute p10141; +execute p10141; col1 | col2 ------+------ -3 | 10 (1 row) - -prepare p1021 as select * from test_bypass_sql_partition where col1=$1 limit 1; -explain execute p1021(1); + +prepare p1021 as select * from test_bypass_sql_partition where col1=$1 limit 1; +explain execute p1021(1); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -269,16 +270,16 @@ explain execute p1021(1); Selected Partitions: PART (7 rows) -execute p1021(1); +execute p1021(1); col1 | col2 | col3 ------+------+--------- 1 | 0 | aaaaaaa (1 row) ---bypass through index only scan - -prepare p10211 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1; -explain execute p10211(1); +--bypass through index only scan + +prepare p10211 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1; +explain execute p10211(1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -290,14 +291,14 @@ explain execute p10211(1); Selected Partitions: PART (7 rows) -execute p10211(1); +execute p10211(1); col1 | col2 ------+------ 1 | 0 (1 row) -prepare p10212 as select col1,col2 from test_bypass_sql_partition where col1=$1 offset 1; -explain execute p10212(1); +prepare p10212 as select col1,col2 from test_bypass_sql_partition where col1=$1 offset 1; +explain execute p10212(1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -309,7 +310,7 @@ explain execute p10212(1); Selected Partitions: PART (7 rows) -execute p10212(1); +execute p10212(1); col1 | col2 ------+------ 1 | 2 @@ -325,8 +326,8 @@ execute p10212(1); 1 | 100 (11 rows) -prepare p10213 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1 offset null; -explain execute p10213(1); +prepare p10213 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1 offset null; +explain execute p10213(1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -338,14 +339,14 @@ explain execute p10213(1); Selected Partitions: PART (7 rows) -execute p10213(1); +execute p10213(1); col1 | col2 ------+------ 1 | 0 (1 row) -prepare p10214 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit null offset null; -explain execute p10214(1); +prepare p10214 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit null offset null; +explain execute p10214(1); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -357,7 +358,7 @@ explain execute p10214(1); Selected Partitions: PART (7 rows) -execute p10214(1); +execute p10214(1); col1 | col2 ------+------ 1 | 0 @@ -374,25 +375,25 @@ execute p10214(1); 1 | 100 (12 rows) - - - -prepare p1024 as select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 1; -prepare p1025 as select * from test_bypass_sql_partition where col1=$1 for update limit 1; -execute p1024; + + + +prepare p1024 as select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 1; +prepare p1025 as select * from test_bypass_sql_partition where col1=$1 for update limit 1; +execute p1024; col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update (1 row) -execute p1025(1); +execute p1025(1); col1 | col2 | col3 ------+------+--------- 1 | 0 | aaaaaaa (1 row) -prepare p104 as select * from test_bypass_sql_partition where col1=$1 order by col1; -execute p104 (3); +prepare p104 as select * from test_bypass_sql_partition where col1=$1 order by col1; +execute p104 (3); col1 | col2 | col3 ------+------+--------- 3 | 0 | aaaaaaa @@ -408,16 +409,16 @@ execute p104 (3); 3 | 100 | aaaaaaa (11 rows) -prepare p1052 as select col1,col2 from test_bypass_sql_partition where col1=$1 order by col1 for update limit 2; -execute p1052(2); +prepare p1052 as select col1,col2 from test_bypass_sql_partition where col1=$1 order by col1 for update limit 2; +execute p1052(2); col1 | col2 ------+------ 2 | 0 2 | 10 (2 rows) -prepare p10601 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col1<$2 and col2>$3 order by col1; -execute p10601 (0,10,1); +prepare p10601 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col1<$2 and col2>$3 order by col1; +execute p10601 (0,10,1); col1 | col2 ------+------ 1 | 2 @@ -513,17 +514,17 @@ execute p10601 (0,10,1); 9 | 100 (91 rows) - ---nobypass -prepare p1020 as select * from test_bypass_sql_partition where col1>0 order by col1 limit 1; -execute p1020; + +--nobypass +prepare p1020 as select * from test_bypass_sql_partition where col1>0 order by col1 limit 1; +execute p1020; col1 | col2 | col3 ------+------+--------- 1 | 0 | aaaaaaa (1 row) -prepare p10200 as select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1; -explain execute p10200; +prepare p10200 as select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1; +explain execute p10200; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not support query in multiple partitions. @@ -535,14 +536,14 @@ explain execute p10200; Selected Partitions: 1..8 (7 rows) -execute p10200; +execute p10200; col1 | col2 ------+------ 1 | 0 (1 row) -prepare p1022 as select * from test_bypass_sql_partition where col1=$1 limit $2; -explain execute p1022(0,3); +prepare p1022 as select * from test_bypass_sql_partition where col1=$1 limit $2; +explain execute p1022(0,3); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit grammar with a non-constant value. @@ -554,7 +555,7 @@ explain execute p1022(0,3); Selected Partitions: PART (7 rows) -execute p1022(0,3); +execute p1022(0,3); col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update @@ -562,7 +563,7 @@ execute p1022(0,3); 0 | 1 | test (3 rows) -explain execute p1022(0,null); +explain execute p1022(0,null); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit grammar with a non-constant value. @@ -574,7 +575,7 @@ explain execute p1022(0,null); Selected Partitions: PART (7 rows) -execute p1022(0,null); +execute p1022(0,null); col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update @@ -691,8 +692,8 @@ execute p1022(0,null); 0 | 100 | aaaaaaa (112 rows) -prepare p1023 as select * from test_bypass_sql_partition where col1=$1 limit $2 offset $3; -explain execute p1023(0,3,2); +prepare p1023 as select * from test_bypass_sql_partition where col1=$1 limit $2 offset $3; +explain execute p1023(0,3,2); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit grammar with a non-constant value. @@ -704,7 +705,7 @@ explain execute p1023(0,3,2); Selected Partitions: PART (7 rows) -execute p1023(0,3,2); +execute p1023(0,3,2); col1 | col2 | col3 ------+------+------ 0 | 1 | test @@ -712,9 +713,9 @@ execute p1023(0,3,2); 0 | 3 | test (3 rows) -prepare p1026 as select * from test_bypass_sql_partition where col1=$1 for update limit $2; -prepare p1027 as select * from test_bypass_sql_partition where col1=$1 for update limit $2 offset $3; -explain execute p1026(0,3); +prepare p1026 as select * from test_bypass_sql_partition where col1=$1 for update limit $2; +prepare p1027 as select * from test_bypass_sql_partition where col1=$1 for update limit $2 offset $3; +explain execute p1026(0,3); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit grammar with a non-constant value. @@ -727,7 +728,7 @@ explain execute p1026(0,3); Selected Partitions: PART (8 rows) -execute p1026(0,3); +execute p1026(0,3); col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update @@ -735,7 +736,7 @@ execute p1026(0,3); 0 | 1 | test (3 rows) -explain execute p1027(0,3,2); +explain execute p1027(0,3,2); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query used limit grammar with a non-constant value. @@ -748,7 +749,7 @@ explain execute p1027(0,3,2); Selected Partitions: PART (8 rows) -execute p1027(0,3,2); +execute p1027(0,3,2); col1 | col2 | col3 ------+------+------ 0 | 1 | test @@ -756,24 +757,24 @@ execute p1027(0,3,2); 0 | 3 | test (3 rows) -prepare p103 as select col1,col2 from test_bypass_sql_partition where col2=$1 order by col1; -execute p103 (2); +prepare p103 as select col1,col2 from test_bypass_sql_partition where col2=$1 order by col1; +execute p103 (2); col1 | col2 ------+------ 0 | 2 1 | 2 (2 rows) -prepare p105 as select col1,col2 from test_bypass_sql_partition where col1<$1 order by col1 limit 2; -execute p105 (5); +prepare p105 as select col1,col2 from test_bypass_sql_partition where col1<$1 order by col1 limit 2; +execute p105 (5); col1 | col2 ------+------ -3 | 10 -1 | 111 (2 rows) -prepare p1051 as select col1,col2 from test_bypass_sql_partition where col1<$1 and col1>$2 order by col1 limit 3; -execute p1051(5,3); +prepare p1051 as select col1,col2 from test_bypass_sql_partition where col1<$1 and col1>$2 order by col1 limit 3; +execute p1051(5,3); col1 | col2 ------+------ 4 | 0 @@ -781,8 +782,8 @@ execute p1051(5,3); 4 | 20 (3 rows) -prepare p106 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col2>$2 order by col1 limit 3; -execute p106 (0,1); +prepare p106 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col2>$2 order by col1 limit 3; +execute p106 (0,1); col1 | col2 ------+------ 1 | 2 @@ -790,16 +791,16 @@ execute p106 (0,1); 1 | 20 (3 rows) - ---bypass -prepare p17 as select * from test_bypass_sql_partition where col1=$1 and col2=$2 for update; -execute p17 (3,3); + +--bypass +prepare p17 as select * from test_bypass_sql_partition where col1=$1 and col2=$2 for update; +execute p17 (3,3); col1 | col2 | col3 ------+------+------ (0 rows) -prepare p18 as update test_bypass_sql_partition set col2=$1*$2 where col1=$3 and col2=$4; -explain execute p18(3,7,3,3); +prepare p18 as update test_bypass_sql_partition set col2=$1*$2 where col1=$3 and col2=$4; +explain execute p18(3,7,3,3); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -811,9 +812,9 @@ explain execute p18(3,7,3,3); Selected Partitions: PART (7 rows) -execute p18(3,7,3,3); -prepare p111 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 desc; -execute p111; +execute p18(3,7,3,3); +prepare p111 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 desc; +execute p111; col1 | col2 ------+------ 19 | 100 @@ -918,8 +919,8 @@ execute p111; 11 | 0 (100 rows) -prepare p112 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 limit 10; -execute p112; +prepare p112 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 limit 10; +execute p112; col1 | col2 ------+------ 11 | 0 @@ -934,9 +935,9 @@ execute p112; 11 | 90 (10 rows) ---nobypass -prepare p181 as update test_bypass_sql_partition set col2= $1 where col1 is null; -explain execute p181(111); +--nobypass +prepare p181 as update test_bypass_sql_partition set col2= $1 where col1 is null; +explain execute p181(111); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because the partition key is not in the parameters. @@ -948,23 +949,23 @@ explain execute p181(111); Selected Partitions: NONE (7 rows) -execute p181(111); - -prepare p191 as select * from test_bypass_sql_partition where col1 is null and col2 is null; -prepare p192 as delete from test_bypass_sql_partition where col1 is null and col2 is null; -execute p191; +execute p181(111); + +prepare p191 as select * from test_bypass_sql_partition where col1 is null and col2 is null; +prepare p192 as delete from test_bypass_sql_partition where col1 is null and col2 is null; +execute p191; col1 | col2 | col3 ------+------+------ (0 rows) -execute p192; - ---error -execute p11(null,null,'test_null'); +execute p192; + +--error +execute p11(null,null,'test_null'); ERROR: inserted partition key does not map to any table partition ---bypass through index only scan -prepare p11301 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2 desc; -explain execute p11301 (2); +--bypass through index only scan +prepare p11301 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2 desc; +explain execute p11301 (2); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -975,7 +976,7 @@ explain execute p11301 (2); Selected Partitions: PART (6 rows) -execute p11301 (2); +execute p11301 (2); col1 | col2 ------+------ 2 | 100 @@ -991,8 +992,8 @@ execute p11301 (2); 2 | 0 (11 rows) -prepare p11401 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2; -explain execute p11401 (2); +prepare p11401 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2; +explain execute p11401 (2); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ [Bypass] @@ -1003,7 +1004,7 @@ explain execute p11401 (2); Selected Partitions: PART (6 rows) -execute p11401 (2); +execute p11401 (2); col1 | col2 ------+------ 2 | 0 @@ -1019,8 +1020,8 @@ execute p11401 (2); 2 | 100 (11 rows) -set enable_indexonlyscan=off; -explain execute p11301 (2); +set enable_indexonlyscan=off; +explain execute p11301 (2); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------- [Bypass] @@ -1031,7 +1032,7 @@ explain execute p11301 (2); Selected Partitions: PART (6 rows) -execute p11401 (2); +execute p11401 (2); col1 | col2 ------+------ 2 | 0 @@ -1047,13 +1048,13 @@ execute p11401 (2); 2 | 100 (11 rows) -reset enable_indexonlyscan; ---nobypass -prepare p120 as insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1>$1 and col1<$2; -execute p120 (0, 9); ---not bypass -prepare p115 as select * from test_bypass_sql_partition order by col2 desc; -explain execute p115; +reset enable_indexonlyscan; +--nobypass +prepare p120 as insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1>$1 and col1<$2; +execute p120 (0, 9); +--not bypass +prepare p115 as select * from test_bypass_sql_partition order by col2 desc; +explain execute p115; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -1065,7 +1066,7 @@ explain execute p115; Selected Partitions: 1..8 (7 rows) -execute p115; +execute p115; col1 | col2 | col3 ------+------+-------------- -1 | 111 | test_update2 @@ -2149,8 +2150,8 @@ execute p115; 0 | -1 | test_update (1079 rows) -prepare p116 as select * from test_bypass_sql_partition order by col2; -explain execute p116; +prepare p116 as select * from test_bypass_sql_partition order by col2; +explain execute p116; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------- [No Bypass]reason: Bypass not executed because query's scan operator is not index. @@ -2162,7 +2163,7 @@ explain execute p116; Selected Partitions: 1..8 (7 rows) -execute p116; +execute p116; col1 | col2 | col3 ------+------+-------------- 0 | -1 | test_update @@ -3246,10 +3247,10 @@ execute p116; -1 | 111 | test_update2 (1079 rows) -prepare p117 as select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; -prepare p118 as select col2, col1 from test_bypass_sql_partition order by col1 limit 10; -prepare p119 as select col1, col2 from test_bypass_sql_partition order by col1 desc limit 10; -execute p117; +prepare p117 as select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +prepare p118 as select col2, col1 from test_bypass_sql_partition order by col1 limit 10; +prepare p119 as select col1, col2 from test_bypass_sql_partition order by col1 desc limit 10; +execute p117; col1 | col2 ------+------ -3 | 10 @@ -3264,7 +3265,7 @@ execute p117; 0 | 6 (10 rows) -execute p118; +execute p118; col2 | col1 ------+------ 10 | -3 @@ -3279,7 +3280,7 @@ execute p118; 6 | 0 (10 rows) -execute p119; +execute p119; col1 | col2 ------+------ 79 | 100 @@ -3294,11 +3295,11 @@ execute p119; 79 | 10 (10 rows) - - ---bypass -prepare p_select1 as select * from test_bypass_sql_partition where col1 = $1 limit 10; -execute p_select1(0); + + +--bypass +prepare p_select1 as select * from test_bypass_sql_partition where col1 = $1 limit 10; +execute p_select1(0); col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update @@ -3313,8 +3314,8 @@ execute p_select1(0); 0 | 8 | test (10 rows) -prepare p_select2 as select * from test_bypass_sql_partition where col1 = $1 limit 10 for update; -execute p_select2(0); +prepare p_select2 as select * from test_bypass_sql_partition where col1 = $1 limit 10 for update; +execute p_select2(0); col1 | col2 | col3 ------+------+------------- 0 | -1 | test_update @@ -3329,12 +3330,12 @@ execute p_select2(0); 0 | 8 | test (10 rows) - ---nobypass - - -prepare p_select3 as select col1, col2 from test_bypass_sql_partition limit 10; -execute p_select3; + +--nobypass + + +prepare p_select3 as select col1, col2 from test_bypass_sql_partition limit 10; +execute p_select3; col1 | col2 ------+------ -3 | 10 @@ -3349,9 +3350,9 @@ execute p_select3; 0 | 6 (10 rows) - -prepare p_select4 as select col1, col2 from test_bypass_sql_partition where col1 < $1 and col1 > $2 limit 10; -execute p_select4(20,10); + +prepare p_select4 as select col1, col2 from test_bypass_sql_partition where col1 < $1 and col1 > $2 limit 10; +execute p_select4(20,10); col1 | col2 ------+------ 11 | 0 @@ -3366,40 +3367,40 @@ execute p_select4(20,10); 11 | 90 (10 rows) -prepare p_select5 as select col1, col2 from test_bypass_sql_partition where col1 <= $1 and col1 >=$2 limit 10; -execute p_select5(11,15); +prepare p_select5 as select col1, col2 from test_bypass_sql_partition where col1 <= $1 and col1 >=$2 limit 10; +execute p_select5(11,15); col1 | col2 ------+------ (0 rows) ---bypass -prepare p_update1 as update test_bypass_sql_partition set col3=$1 where col1=$2; -execute p_update1(1, 10); -prepare p_update2 as update test_bypass_sql_partition set col3=$1,col2=col1-$2 where col1=$3; -execute p_update2('test_null',1,1); ---nobypass -update test_bypass_sql_partition set col3='test_null' where col1 < 70; -update test_bypass_sql_partition set col3='test_null' where true; -update test_bypass_sql_partition set col1 = 1 where col1 > 1 and col1 < 10; -prepare p_update3 as update test_bypass_sql_partition set col1 = $1 where col1 > $2 and col1 < $3; -execute p_update3(1,1,10); - -prepare p_update4 as update test_bypass_sql_partition set col3=$1,col2=mod(5,3) where col1 > $2 and col1 < $3; -execute p_update4('test_null',11,15); -prepare p_update5 as update test_bypass_sql_partition set col3=$1,col2=col1-1 where col1 >= $2 and col1 <= $3; -execute p_update5('test_null',1,10); - ---bypass -prepare p_delete1 as delete from test_bypass_sql_partition where col1=$1; -execute p_delete1 (1); - ---nobypass -prepare p_delete3 as delete from test_bypass_sql_partition where col1 > $1 and col1 < $2; -execute p_delete3(1,10); -prepare p_delete4 as delete from test_bypass_sql_partition where col1 <= $1 and col1 >= $2; -execute p_delete4(1,10); -prepare p_delete2 as delete from test_bypass_sql_partition where true; -execute p_delete2; -reset enable_partition_opfusion; -drop table test_bypass_sql_partition; - +--bypass +prepare p_update1 as update test_bypass_sql_partition set col3=$1 where col1=$2; +execute p_update1(1, 10); +prepare p_update2 as update test_bypass_sql_partition set col3=$1,col2=col1-$2 where col1=$3; +execute p_update2('test_null',1,1); +--nobypass +update test_bypass_sql_partition set col3='test_null' where col1 < 70; +update test_bypass_sql_partition set col3='test_null' where true; +update test_bypass_sql_partition set col1 = 1 where col1 > 1 and col1 < 10; +prepare p_update3 as update test_bypass_sql_partition set col1 = $1 where col1 > $2 and col1 < $3; +execute p_update3(1,1,10); + +prepare p_update4 as update test_bypass_sql_partition set col3=$1,col2=mod(5,3) where col1 > $2 and col1 < $3; +execute p_update4('test_null',11,15); +prepare p_update5 as update test_bypass_sql_partition set col3=$1,col2=col1-1 where col1 >= $2 and col1 <= $3; +execute p_update5('test_null',1,10); + +--bypass +prepare p_delete1 as delete from test_bypass_sql_partition where col1=$1; +execute p_delete1 (1); + +--nobypass +prepare p_delete3 as delete from test_bypass_sql_partition where col1 > $1 and col1 < $2; +execute p_delete3(1,10); +prepare p_delete4 as delete from test_bypass_sql_partition where col1 <= $1 and col1 >= $2; +execute p_delete4(1,10); +prepare p_delete2 as delete from test_bypass_sql_partition where true; +execute p_delete2; +reset enable_partition_opfusion; +drop table test_bypass_sql_partition; + diff --git a/src/test/regress/sql/bypass_preparedexecute_support.sql b/src/test/regress/sql/bypass_preparedexecute_support.sql index 1cbeab61..011ae1c8 100644 --- a/src/test/regress/sql/bypass_preparedexecute_support.sql +++ b/src/test/regress/sql/bypass_preparedexecute_support.sql @@ -7,6 +7,7 @@ set enable_seqscan=off; set opfusion_debug_mode = 'log'; set log_min_messages=debug; set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; drop table if exists test_bypass_sq1; create table test_bypass_sq1(col1 int, col2 int, col3 text); diff --git a/src/test/regress/sql/bypass_simplequery_support.sql b/src/test/regress/sql/bypass_simplequery_support.sql index d3d3937f..5e9bf0b7 100644 --- a/src/test/regress/sql/bypass_simplequery_support.sql +++ b/src/test/regress/sql/bypass_simplequery_support.sql @@ -7,6 +7,7 @@ set enable_seqscan=off; set opfusion_debug_mode = 'log'; set log_min_messages=debug; set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; -- create table drop table if exists test_bypass_sq1; diff --git a/src/test/regress/sql/sqlbypass_partition.sql b/src/test/regress/sql/sqlbypass_partition.sql index 756be8b8..d929e76b 100644 --- a/src/test/regress/sql/sqlbypass_partition.sql +++ b/src/test/regress/sql/sqlbypass_partition.sql @@ -1,254 +1,255 @@ -set enable_opfusion=on; -set enable_partition_opfusion=on; -set enable_bitmapscan=off; -set enable_seqscan=off; -set opfusion_debug_mode = 'log'; -set log_min_messages=debug; -set logging_module = 'on(OPFUSION)'; ---create table -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; ---insert -explain insert into test_bypass_sql_partition values (0,0,'test_insert'); -insert into test_bypass_sql_partition values (0,0,'test_insert'); -explain insert into test_bypass_sql_partition values (0,1,'test_insert'); -insert into test_bypass_sql_partition values (0,1,'test_insert'); -explain insert into test_bypass_sql_partition values (11,1,'test_insert'); -insert into test_bypass_sql_partition values (11,1,'test_insert'); -explain insert into test_bypass_sql_partition values (11,2,'test_insert'); -insert into test_bypass_sql_partition values (11,2,'test_insert'); -explain insert into test_bypass_sql_partition values (0,10,'test_insert2'); -insert into test_bypass_sql_partition values (0,10,'test_insert2'); -explain insert into test_bypass_sql_partition values (2,12,'test_insert2'); -insert into test_bypass_sql_partition values (2,12,'test_insert2'); -explain insert into test_bypass_sql_partition values (30,0,'test_insert3'); -insert into test_bypass_sql_partition values (30,0,'test_insert3'); -explain insert into test_bypass_sql_partition values (3,3,'test_insert3'); -insert into test_bypass_sql_partition values (3,3,'test_insert3'); -explain insert into test_bypass_sql_partition(col1,col2) values (1,1); -insert into test_bypass_sql_partition(col1,col2) values (1,1); -explain insert into test_bypass_sql_partition(col1,col2) values (22,2); -insert into test_bypass_sql_partition(col1,col2) values (22,2); -explain insert into test_bypass_sql_partition(col1,col2) values (33,3); -insert into test_bypass_sql_partition(col1,col2) values (33,3); ---error -explain insert into test_bypass_sql_partition values (null,null,null); -insert into test_bypass_sql_partition values (null,null,null); ---nobypass -explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); -insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); ---select -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); ---bypass -set enable_indexonlyscan=off; -explain select * from test_bypass_sql_partition where col1=0 and col2=0; -select * from test_bypass_sql_partition where col1=0 and col2=0; -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; -explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; -select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; - -explain select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; -select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; -explain select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; -select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; -explain select * from test_bypass_sql_partition where col1=0 and col2=-1; -select * from test_bypass_sql_partition where col1=0 and col2=-1; -reset enable_indexonlyscan; ---bypass though index only scan -set enable_indexscan = off; -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; -explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; -select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; -reset enable_indexscan; ---error -explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; -select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; -explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; -select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; ---nobypass -explain select * from test_bypass_sql_partition where col1 is null and col2 is null; -select * from test_bypass_sql_partition where col1 is null and col2 is null; -select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; -explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; -select col1, col2 from test_bypass_sql_partition order by col1 limit 10; -explain select col1, col2 from test_bypass_sql_partition order by col1 limit 10; -select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; -explain select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; -select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; -explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; - ---update ---bypass - -explain update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=0 and col2=0; -update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=10 and col2=0; -explain update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; -update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; -explain update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; -update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; ---not bypass -explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); -explain select * from test_bypass_sql_partition where col3 is not null; -explain update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; -update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; - - ---bypass -explain update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; -update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; -explain select * from test_bypass_sql_partition where col1=0 order by col1; -select * from test_bypass_sql_partition where col1=0 order by col1; -explain select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; -select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; -explain select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; -select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; - ---nobypass -explain select * from test_bypass_sql_partition where col2=20 order by col1; -select * from test_bypass_sql_partition where col2=20 order by col1; -explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; -explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; -select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; -explain select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; -explain select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; -select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; - - -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( -partition test_bypass_sql_partition_1 values less than(10), -partition test_bypass_sql_partition_2 values less than(20), -partition test_bypass_sql_partition_3 values less than(30), -partition test_bypass_sql_partition_4 values less than(40), -partition test_bypass_sql_partition_5 values less than(50), -partition test_bypass_sql_partition_6 values less than(60), -partition test_bypass_sql_partition_7 values less than(70), -partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); - ---bypass though index only scan -set enable_indexscan = off; -explain select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; -select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; -explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; -select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; ---nobypass -explain select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; -select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; - -explain select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; -select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; - -explain select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; -explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; -select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; - -reset enable_indexscan; - ---nobypass -explain select * from test_bypass_sql_partition where col1>col2 limit 10; -explain select * from test_bypass_sql_partition where col1=3 and col2=3 for update; -select * from test_bypass_sql_partition where col1=3 and col2=3 for update; -explain select * from test_bypass_sql_partition where col3='test_update2'; - -explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; -select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset 3; -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset null; -explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; -select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; -explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update offset 3; -explain update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; -update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; -explain delete from test_bypass_sql_partition where col1=1 and col2=1; -delete from test_bypass_sql_partition where col1=1 and col2=1; ---error -explain delete from test_bypass_sql_partition where col1 is null and col2 is null; -delete from test_bypass_sql_partition where col1 is null and col2 is null; -explain insert into test_bypass_sql_partition values (null,null,null); -insert into test_bypass_sql_partition values (null,null,null); ---bypass / set enable_bitmapscan=off; -select * from test_bypass_sql_partition where col1=3; -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc; -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10 desc; --order by is supported when ordered col is in index -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; ---not bypass -explain select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; -select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; -explain select * from test_bypass_sql_partition where col1 > 0 order by col1,col2 desc limit 10; ---bypass -explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10 ; -select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10; ---not bypass -explain select * from test_bypass_sql_partition where true; -explain select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; -select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; ---bypass - -select col2, col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; -select col1, col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc limit 10; -explain insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1=0; - -delete from test_bypass_sql_partition where col1=1; -delete from test_bypass_sql_partition where col1 > 10 and col1 < 0; -delete from test_bypass_sql_partition where col1 <= 11 and col1 >= 15; - ---nobypass -delete from test_bypass_sql_partition where col1 > 10; -delete from test_bypass_sql_partition where col1 < 10; -delete from test_bypass_sql_partition where col1 >= 10 and col1 <= 30; -reset enable_partition_opfusion; -drop table test_bypass_sql_partition; - +set enable_opfusion=on; +set enable_partition_opfusion=on; +set enable_bitmapscan=off; +set enable_seqscan=off; +set opfusion_debug_mode = 'log'; +set log_min_messages=debug; +set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; +--create table +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +--insert +explain insert into test_bypass_sql_partition values (0,0,'test_insert'); +insert into test_bypass_sql_partition values (0,0,'test_insert'); +explain insert into test_bypass_sql_partition values (0,1,'test_insert'); +insert into test_bypass_sql_partition values (0,1,'test_insert'); +explain insert into test_bypass_sql_partition values (11,1,'test_insert'); +insert into test_bypass_sql_partition values (11,1,'test_insert'); +explain insert into test_bypass_sql_partition values (11,2,'test_insert'); +insert into test_bypass_sql_partition values (11,2,'test_insert'); +explain insert into test_bypass_sql_partition values (0,10,'test_insert2'); +insert into test_bypass_sql_partition values (0,10,'test_insert2'); +explain insert into test_bypass_sql_partition values (2,12,'test_insert2'); +insert into test_bypass_sql_partition values (2,12,'test_insert2'); +explain insert into test_bypass_sql_partition values (30,0,'test_insert3'); +insert into test_bypass_sql_partition values (30,0,'test_insert3'); +explain insert into test_bypass_sql_partition values (3,3,'test_insert3'); +insert into test_bypass_sql_partition values (3,3,'test_insert3'); +explain insert into test_bypass_sql_partition(col1,col2) values (1,1); +insert into test_bypass_sql_partition(col1,col2) values (1,1); +explain insert into test_bypass_sql_partition(col1,col2) values (22,2); +insert into test_bypass_sql_partition(col1,col2) values (22,2); +explain insert into test_bypass_sql_partition(col1,col2) values (33,3); +insert into test_bypass_sql_partition(col1,col2) values (33,3); +--error +explain insert into test_bypass_sql_partition values (null,null,null); +insert into test_bypass_sql_partition values (null,null,null); +--nobypass +explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +--select +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); +--bypass +set enable_indexonlyscan=off; +explain select * from test_bypass_sql_partition where col1=0 and col2=0; +select * from test_bypass_sql_partition where col1=0 and col2=0; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 and col2 <= 20 order by col1,col2; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 for update limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; +select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 and col2>0 order by col1,col2 limit 0; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=0 order by col1,col2 for update limit 0; + +explain select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; +select col1,col2 from test_bypass_sql_partition where col1 is not null and col2 is not null order by col1,col2; +explain select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; +select * from test_bypass_sql_partition where col1 is not null and col2 = 0 order by col1; +explain select * from test_bypass_sql_partition where col1=0 and col2=-1; +select * from test_bypass_sql_partition where col1=0 and col2=-1; +reset enable_indexonlyscan; +--bypass though index only scan +set enable_indexscan = off; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 1; +explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; +select col1,col2 from test_bypass_sql_partition where col1=10 and col2=10 order by col1 limit 0; +reset enable_indexscan; +--error +explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; +select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 limit -1; +explain select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; +select * from test_bypass_sql_partition where col1=0 and col2=0 order by col1 for update limit -1; +--nobypass +explain select * from test_bypass_sql_partition where col1 is null and col2 is null; +select * from test_bypass_sql_partition where col1 is null and col2 is null; +select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and col1 >= 10 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 > 0 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; +explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order by col1 limit 10; + +--update +--bypass + +explain update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=0 and col2=0; +update test_bypass_sql_partition set col2=col2-1,col3='test_update' where col1=10 and col2=0; +explain update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; +update test_bypass_sql_partition set col2=col1-1,col3='test_update' where col1=20 and col2=2; +explain update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; +update test_bypass_sql_partition set col2=mod(5,3) where col1=1 and col2=10; +--not bypass +explain insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +explain select * from test_bypass_sql_partition where col3 is not null; +explain update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; +update test_bypass_sql_partition set col3='test_null' where col1 is null and col2 is null; + + +--bypass +explain update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; +update test_bypass_sql_partition set col2=111,col3='test_update2' where col1=0; +explain select * from test_bypass_sql_partition where col1=0 order by col1; +select * from test_bypass_sql_partition where col1=0 order by col1; +explain select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; +select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 2; +explain select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; +select * from test_bypass_sql_partition where col1=1 and col2=20 order by col1 for update limit 1; + +--nobypass +explain select * from test_bypass_sql_partition where col2=20 order by col1; +select * from test_bypass_sql_partition where col2=20 order by col1; +explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; +select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 3; +explain select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col2<50 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 10; +explain select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; +select * from test_bypass_sql_partition where col1>=0 and col2>0 order by col1 limit 3; + + +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( +partition test_bypass_sql_partition_1 values less than(10), +partition test_bypass_sql_partition_2 values less than(20), +partition test_bypass_sql_partition_3 values less than(30), +partition test_bypass_sql_partition_4 values less than(40), +partition test_bypass_sql_partition_5 values less than(50), +partition test_bypass_sql_partition_6 values less than(60), +partition test_bypass_sql_partition_7 values less than(70), +partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); + +--bypass though index only scan +set enable_indexscan = off; +explain select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; +select col1,col2 from test_bypass_sql_partition where col1=0 order by col2; +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; +select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 3; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit 3; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<10 and col2>0 order by col1 limit null; +--nobypass +explain select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; +select col2,col1 from test_bypass_sql_partition where col2=2 order by col1 limit 10; + +explain select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; +select col1,col2 from test_bypass_sql_partition where col1 is null and col2 is null limit 10; + +explain select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col2<5 order by col1 limit 10; +explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; +select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=10 and col2>0 order by col1 limit 10; + +reset enable_indexscan; + +--nobypass +explain select * from test_bypass_sql_partition where col1>col2 limit 10; +explain select * from test_bypass_sql_partition where col1=3 and col2=3 for update; +select * from test_bypass_sql_partition where col1=3 and col2=3 for update; +explain select * from test_bypass_sql_partition where col3='test_update2'; + +explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; +select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 limit 3 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update limit 3 offset null; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; +select * from test_bypass_sql_partition where col1>0 and col1<10 and col2>0 order by col1 offset 3; +explain select * from test_bypass_sql_partition where col1>0 and col1<10 order by col1 for update offset 3; +explain update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; +update test_bypass_sql_partition set col2=3*7 where col1=3 and col2=2; +explain delete from test_bypass_sql_partition where col1=1 and col2=1; +delete from test_bypass_sql_partition where col1=1 and col2=1; +--error +explain delete from test_bypass_sql_partition where col1 is null and col2 is null; +delete from test_bypass_sql_partition where col1 is null and col2 is null; +explain insert into test_bypass_sql_partition values (null,null,null); +insert into test_bypass_sql_partition values (null,null,null); +--bypass / set enable_bitmapscan=off; +select * from test_bypass_sql_partition where col1=3; +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10 desc; --order by is supported when ordered col is in index +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 limit 10 order by col1; +--not bypass +explain select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; +select col1,col2 from test_bypass_sql_partition order by col1,col2 limit 10; +explain select * from test_bypass_sql_partition where col1 > 0 order by col1,col2 desc limit 10; +--bypass +explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10 ; +select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1,col2 limit 10; +--not bypass +explain select * from test_bypass_sql_partition where true; +explain select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +--bypass + +select col2, col1 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 limit 10; +select col1, col2 from test_bypass_sql_partition where col1>0 and col1<10 order by col1 desc limit 10; +explain insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1=0; + +delete from test_bypass_sql_partition where col1=1; +delete from test_bypass_sql_partition where col1 > 10 and col1 < 0; +delete from test_bypass_sql_partition where col1 <= 11 and col1 >= 15; + +--nobypass +delete from test_bypass_sql_partition where col1 > 10; +delete from test_bypass_sql_partition where col1 < 10; +delete from test_bypass_sql_partition where col1 >= 10 and col1 <= 30; +reset enable_partition_opfusion; +drop table test_bypass_sql_partition; + diff --git a/src/test/regress/sql/sqlbypass_partition_prepare.sql b/src/test/regress/sql/sqlbypass_partition_prepare.sql index 7f774863..f30289f4 100644 --- a/src/test/regress/sql/sqlbypass_partition_prepare.sql +++ b/src/test/regress/sql/sqlbypass_partition_prepare.sql @@ -1,245 +1,246 @@ -set enable_opfusion=on; -set enable_partition_opfusion=on; -set enable_bitmapscan=off; -set enable_seqscan=off; -set opfusion_debug_mode = 'log'; -set log_min_messages=debug; -set logging_module = 'on(OPFUSION)'; ---create table -drop table if exists test_bypass_sql_partition; -create table test_bypass_sql_partition(col1 int, col2 int, col3 text) -partition by range (col1) -( - partition test_bypass_sql_partition_1 values less than(10), - partition test_bypass_sql_partition_2 values less than(20), - partition test_bypass_sql_partition_3 values less than(30), - partition test_bypass_sql_partition_4 values less than(40), - partition test_bypass_sql_partition_5 values less than(50), - partition test_bypass_sql_partition_6 values less than(60), - partition test_bypass_sql_partition_7 values less than(70), - partition test_bypass_sql_partition_8 values less than(80) -); -create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; -insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); -prepare p11 as insert into test_bypass_sql_partition values($1,$2,$3); -prepare p12 as insert into test_bypass_sql_partition(col1,col2) values ($1,$2); - - - -explain execute p11(0,0,'test_insert'); -execute p11(10,10,'test_insert'); -execute p11(12,12,'test_insert'); -execute p11(-1,-1,'test_insert2'); -execute p11(23,23,'test_insert2'); -execute p11(33,33,'test_insert3'); -execute p11(0,0,'test_insert3'); -explain execute p12(1,1); -execute p12(1,1); -execute p12(22,22); -execute p12(20,20); - ---nobypass -execute p11(null,null,null); -prepare p_insert1 as insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); -execute p_insert1; ---bypass -prepare p13 as select * from test_bypass_sql_partition where col1=$1 and col2=$2; -explain execute p13(0,0); -execute p13(0,0); -execute p13(10,0); -execute p13(20,0); -execute p13(30,0); -execute p13(40,0); -set enable_indexonlyscan=off; -explain execute p13(0,0); -execute p13(0,0); -reset enable_indexonlyscan; -prepare p15 as update test_bypass_sql_partition set col2=col2+$4,col3=$3 where col1=$1 and col2=$2; -explain execute p15 (0,0,'test_update',-1); -execute p15 (0,0,'test_update',-1); -prepare p16 as update test_bypass_sql_partition set col2=mod($1,$2) where col1=$3 and col2=$4; -explain execute p16(5,3,1,1); -execute p16(5,3,1,1); - - -prepare p101 as update test_bypass_sql_partition set col2=$1,col3=$2 where col1=$3 ; -execute p101 (111,'test_update2',-1); -prepare p102 as select * from test_bypass_sql_partition where col1=$1; -execute p102 (1); - - -prepare p1011 as insert into test_bypass_sql_partition values(-3,-3,'test_pbe'); -prepare p1013 as update test_bypass_sql_partition set col2=10 where col1=-3; -prepare p1012 as select * from test_bypass_sql_partition where col1=-3; -prepare p1014 as select * from test_bypass_sql_partition where col1=-3 for update; -prepare p1015 as delete from test_bypass_sql_partition where col1=-3; -explain execute p1011; -execute p1011; -explain execute p1012; -execute p1012; -explain execute p1013; -execute p1013; -explain execute p1014; -execute p1014; -prepare p10141 as select col1,col2 from test_bypass_sql_partition where col1=-3 for update; -explain execute p10141; -execute p10141; - -prepare p1021 as select * from test_bypass_sql_partition where col1=$1 limit 1; -explain execute p1021(1); -execute p1021(1); ---bypass through index only scan - -prepare p10211 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1; -explain execute p10211(1); -execute p10211(1); -prepare p10212 as select col1,col2 from test_bypass_sql_partition where col1=$1 offset 1; -explain execute p10212(1); -execute p10212(1); -prepare p10213 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1 offset null; -explain execute p10213(1); -execute p10213(1); -prepare p10214 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit null offset null; -explain execute p10214(1); -execute p10214(1); - - - -prepare p1024 as select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 1; -prepare p1025 as select * from test_bypass_sql_partition where col1=$1 for update limit 1; -execute p1024; -execute p1025(1); -prepare p104 as select * from test_bypass_sql_partition where col1=$1 order by col1; -execute p104 (3); -prepare p1052 as select col1,col2 from test_bypass_sql_partition where col1=$1 order by col1 for update limit 2; -execute p1052(2); -prepare p10601 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col1<$2 and col2>$3 order by col1; -execute p10601 (0,10,1); - ---nobypass -prepare p1020 as select * from test_bypass_sql_partition where col1>0 order by col1 limit 1; -execute p1020; -prepare p10200 as select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1; -explain execute p10200; -execute p10200; -prepare p1022 as select * from test_bypass_sql_partition where col1=$1 limit $2; -explain execute p1022(0,3); -execute p1022(0,3); -explain execute p1022(0,null); -execute p1022(0,null); -prepare p1023 as select * from test_bypass_sql_partition where col1=$1 limit $2 offset $3; -explain execute p1023(0,3,2); -execute p1023(0,3,2); -prepare p1026 as select * from test_bypass_sql_partition where col1=$1 for update limit $2; -prepare p1027 as select * from test_bypass_sql_partition where col1=$1 for update limit $2 offset $3; -explain execute p1026(0,3); -execute p1026(0,3); -explain execute p1027(0,3,2); -execute p1027(0,3,2); -prepare p103 as select col1,col2 from test_bypass_sql_partition where col2=$1 order by col1; -execute p103 (2); -prepare p105 as select col1,col2 from test_bypass_sql_partition where col1<$1 order by col1 limit 2; -execute p105 (5); -prepare p1051 as select col1,col2 from test_bypass_sql_partition where col1<$1 and col1>$2 order by col1 limit 3; -execute p1051(5,3); -prepare p106 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col2>$2 order by col1 limit 3; -execute p106 (0,1); - ---bypass -prepare p17 as select * from test_bypass_sql_partition where col1=$1 and col2=$2 for update; -execute p17 (3,3); -prepare p18 as update test_bypass_sql_partition set col2=$1*$2 where col1=$3 and col2=$4; -explain execute p18(3,7,3,3); -execute p18(3,7,3,3); -prepare p111 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 desc; -execute p111; -prepare p112 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 limit 10; -execute p112; ---nobypass -prepare p181 as update test_bypass_sql_partition set col2= $1 where col1 is null; -explain execute p181(111); -execute p181(111); - -prepare p191 as select * from test_bypass_sql_partition where col1 is null and col2 is null; -prepare p192 as delete from test_bypass_sql_partition where col1 is null and col2 is null; -execute p191; -execute p192; - ---error -execute p11(null,null,'test_null'); ---bypass through index only scan -prepare p11301 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2 desc; -explain execute p11301 (2); -execute p11301 (2); -prepare p11401 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2; -explain execute p11401 (2); -execute p11401 (2); -set enable_indexonlyscan=off; -explain execute p11301 (2); -execute p11401 (2); -reset enable_indexonlyscan; ---nobypass -prepare p120 as insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1>$1 and col1<$2; -execute p120 (0, 9); ---not bypass -prepare p115 as select * from test_bypass_sql_partition order by col2 desc; -explain execute p115; -execute p115; -prepare p116 as select * from test_bypass_sql_partition order by col2; -explain execute p116; -execute p116; -prepare p117 as select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; -prepare p118 as select col2, col1 from test_bypass_sql_partition order by col1 limit 10; -prepare p119 as select col1, col2 from test_bypass_sql_partition order by col1 desc limit 10; -execute p117; -execute p118; -execute p119; - - ---bypass -prepare p_select1 as select * from test_bypass_sql_partition where col1 = $1 limit 10; -execute p_select1(0); -prepare p_select2 as select * from test_bypass_sql_partition where col1 = $1 limit 10 for update; -execute p_select2(0); - ---nobypass - - -prepare p_select3 as select col1, col2 from test_bypass_sql_partition limit 10; -execute p_select3; - -prepare p_select4 as select col1, col2 from test_bypass_sql_partition where col1 < $1 and col1 > $2 limit 10; -execute p_select4(20,10); -prepare p_select5 as select col1, col2 from test_bypass_sql_partition where col1 <= $1 and col1 >=$2 limit 10; -execute p_select5(11,15); ---bypass -prepare p_update1 as update test_bypass_sql_partition set col3=$1 where col1=$2; -execute p_update1(1, 10); -prepare p_update2 as update test_bypass_sql_partition set col3=$1,col2=col1-$2 where col1=$3; -execute p_update2('test_null',1,1); ---nobypass -update test_bypass_sql_partition set col3='test_null' where col1 < 70; -update test_bypass_sql_partition set col3='test_null' where true; -update test_bypass_sql_partition set col1 = 1 where col1 > 1 and col1 < 10; -prepare p_update3 as update test_bypass_sql_partition set col1 = $1 where col1 > $2 and col1 < $3; -execute p_update3(1,1,10); - -prepare p_update4 as update test_bypass_sql_partition set col3=$1,col2=mod(5,3) where col1 > $2 and col1 < $3; -execute p_update4('test_null',11,15); -prepare p_update5 as update test_bypass_sql_partition set col3=$1,col2=col1-1 where col1 >= $2 and col1 <= $3; -execute p_update5('test_null',1,10); - ---bypass -prepare p_delete1 as delete from test_bypass_sql_partition where col1=$1; -execute p_delete1 (1); - ---nobypass -prepare p_delete3 as delete from test_bypass_sql_partition where col1 > $1 and col1 < $2; -execute p_delete3(1,10); -prepare p_delete4 as delete from test_bypass_sql_partition where col1 <= $1 and col1 >= $2; -execute p_delete4(1,10); -prepare p_delete2 as delete from test_bypass_sql_partition where true; -execute p_delete2; -reset enable_partition_opfusion; -drop table test_bypass_sql_partition; - +set enable_opfusion=on; +set enable_partition_opfusion=on; +set enable_bitmapscan=off; +set enable_seqscan=off; +set opfusion_debug_mode = 'log'; +set log_min_messages=debug; +set logging_module = 'on(OPFUSION)'; +set sql_beta_feature = 'index_cost_with_leaf_pages_only'; +--create table +drop table if exists test_bypass_sql_partition; +create table test_bypass_sql_partition(col1 int, col2 int, col3 text) +partition by range (col1) +( + partition test_bypass_sql_partition_1 values less than(10), + partition test_bypass_sql_partition_2 values less than(20), + partition test_bypass_sql_partition_3 values less than(30), + partition test_bypass_sql_partition_4 values less than(40), + partition test_bypass_sql_partition_5 values less than(50), + partition test_bypass_sql_partition_6 values less than(60), + partition test_bypass_sql_partition_7 values less than(70), + partition test_bypass_sql_partition_8 values less than(80) +); +create index itest_bypass_sql_partition on test_bypass_sql_partition(col1,col2) local; +insert into test_bypass_sql_partition select generate_series(0,79,1), generate_series(0,100,10), repeat('a',7); +prepare p11 as insert into test_bypass_sql_partition values($1,$2,$3); +prepare p12 as insert into test_bypass_sql_partition(col1,col2) values ($1,$2); + + + +explain execute p11(0,0,'test_insert'); +execute p11(10,10,'test_insert'); +execute p11(12,12,'test_insert'); +execute p11(-1,-1,'test_insert2'); +execute p11(23,23,'test_insert2'); +execute p11(33,33,'test_insert3'); +execute p11(0,0,'test_insert3'); +explain execute p12(1,1); +execute p12(1,1); +execute p12(22,22); +execute p12(20,20); + +--nobypass +execute p11(null,null,null); +prepare p_insert1 as insert into test_bypass_sql_partition values(0,generate_series(1,100),'test'); +execute p_insert1; +--bypass +prepare p13 as select * from test_bypass_sql_partition where col1=$1 and col2=$2; +explain execute p13(0,0); +execute p13(0,0); +execute p13(10,0); +execute p13(20,0); +execute p13(30,0); +execute p13(40,0); +set enable_indexonlyscan=off; +explain execute p13(0,0); +execute p13(0,0); +reset enable_indexonlyscan; +prepare p15 as update test_bypass_sql_partition set col2=col2+$4,col3=$3 where col1=$1 and col2=$2; +explain execute p15 (0,0,'test_update',-1); +execute p15 (0,0,'test_update',-1); +prepare p16 as update test_bypass_sql_partition set col2=mod($1,$2) where col1=$3 and col2=$4; +explain execute p16(5,3,1,1); +execute p16(5,3,1,1); + + +prepare p101 as update test_bypass_sql_partition set col2=$1,col3=$2 where col1=$3 ; +execute p101 (111,'test_update2',-1); +prepare p102 as select * from test_bypass_sql_partition where col1=$1; +execute p102 (1); + + +prepare p1011 as insert into test_bypass_sql_partition values(-3,-3,'test_pbe'); +prepare p1013 as update test_bypass_sql_partition set col2=10 where col1=-3; +prepare p1012 as select * from test_bypass_sql_partition where col1=-3; +prepare p1014 as select * from test_bypass_sql_partition where col1=-3 for update; +prepare p1015 as delete from test_bypass_sql_partition where col1=-3; +explain execute p1011; +execute p1011; +explain execute p1012; +execute p1012; +explain execute p1013; +execute p1013; +explain execute p1014; +execute p1014; +prepare p10141 as select col1,col2 from test_bypass_sql_partition where col1=-3 for update; +explain execute p10141; +execute p10141; + +prepare p1021 as select * from test_bypass_sql_partition where col1=$1 limit 1; +explain execute p1021(1); +execute p1021(1); +--bypass through index only scan + +prepare p10211 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1; +explain execute p10211(1); +execute p10211(1); +prepare p10212 as select col1,col2 from test_bypass_sql_partition where col1=$1 offset 1; +explain execute p10212(1); +execute p10212(1); +prepare p10213 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit 1 offset null; +explain execute p10213(1); +execute p10213(1); +prepare p10214 as select col1,col2 from test_bypass_sql_partition where col1=$1 limit null offset null; +explain execute p10214(1); +execute p10214(1); + + + +prepare p1024 as select * from test_bypass_sql_partition where col1=0 order by col1 for update limit 1; +prepare p1025 as select * from test_bypass_sql_partition where col1=$1 for update limit 1; +execute p1024; +execute p1025(1); +prepare p104 as select * from test_bypass_sql_partition where col1=$1 order by col1; +execute p104 (3); +prepare p1052 as select col1,col2 from test_bypass_sql_partition where col1=$1 order by col1 for update limit 2; +execute p1052(2); +prepare p10601 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col1<$2 and col2>$3 order by col1; +execute p10601 (0,10,1); + +--nobypass +prepare p1020 as select * from test_bypass_sql_partition where col1>0 order by col1 limit 1; +execute p1020; +prepare p10200 as select col1,col2 from test_bypass_sql_partition where col1>0 order by col1 limit 1; +explain execute p10200; +execute p10200; +prepare p1022 as select * from test_bypass_sql_partition where col1=$1 limit $2; +explain execute p1022(0,3); +execute p1022(0,3); +explain execute p1022(0,null); +execute p1022(0,null); +prepare p1023 as select * from test_bypass_sql_partition where col1=$1 limit $2 offset $3; +explain execute p1023(0,3,2); +execute p1023(0,3,2); +prepare p1026 as select * from test_bypass_sql_partition where col1=$1 for update limit $2; +prepare p1027 as select * from test_bypass_sql_partition where col1=$1 for update limit $2 offset $3; +explain execute p1026(0,3); +execute p1026(0,3); +explain execute p1027(0,3,2); +execute p1027(0,3,2); +prepare p103 as select col1,col2 from test_bypass_sql_partition where col2=$1 order by col1; +execute p103 (2); +prepare p105 as select col1,col2 from test_bypass_sql_partition where col1<$1 order by col1 limit 2; +execute p105 (5); +prepare p1051 as select col1,col2 from test_bypass_sql_partition where col1<$1 and col1>$2 order by col1 limit 3; +execute p1051(5,3); +prepare p106 as select col1,col2 from test_bypass_sql_partition where col1>$1 and col2>$2 order by col1 limit 3; +execute p106 (0,1); + +--bypass +prepare p17 as select * from test_bypass_sql_partition where col1=$1 and col2=$2 for update; +execute p17 (3,3); +prepare p18 as update test_bypass_sql_partition set col2=$1*$2 where col1=$3 and col2=$4; +explain execute p18(3,7,3,3); +execute p18(3,7,3,3); +prepare p111 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 desc; +execute p111; +prepare p112 as select col1,col2 from test_bypass_sql_partition where col1>10 and col1<20 order by col1 limit 10; +execute p112; +--nobypass +prepare p181 as update test_bypass_sql_partition set col2= $1 where col1 is null; +explain execute p181(111); +execute p181(111); + +prepare p191 as select * from test_bypass_sql_partition where col1 is null and col2 is null; +prepare p192 as delete from test_bypass_sql_partition where col1 is null and col2 is null; +execute p191; +execute p192; + +--error +execute p11(null,null,'test_null'); +--bypass through index only scan +prepare p11301 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2 desc; +explain execute p11301 (2); +execute p11301 (2); +prepare p11401 as select col1,col2 from test_bypass_sql_partition where col1 = $1 order by col1,col2; +explain execute p11401 (2); +execute p11401 (2); +set enable_indexonlyscan=off; +explain execute p11301 (2); +execute p11401 (2); +reset enable_indexonlyscan; +--nobypass +prepare p120 as insert into test_bypass_sql_partition select * from test_bypass_sql_partition where col1>$1 and col1<$2; +execute p120 (0, 9); +--not bypass +prepare p115 as select * from test_bypass_sql_partition order by col2 desc; +explain execute p115; +execute p115; +prepare p116 as select * from test_bypass_sql_partition order by col2; +explain execute p116; +execute p116; +prepare p117 as select col1, col2 from test_bypass_sql_partition where true order by col1 limit 10; +prepare p118 as select col2, col1 from test_bypass_sql_partition order by col1 limit 10; +prepare p119 as select col1, col2 from test_bypass_sql_partition order by col1 desc limit 10; +execute p117; +execute p118; +execute p119; + + +--bypass +prepare p_select1 as select * from test_bypass_sql_partition where col1 = $1 limit 10; +execute p_select1(0); +prepare p_select2 as select * from test_bypass_sql_partition where col1 = $1 limit 10 for update; +execute p_select2(0); + +--nobypass + + +prepare p_select3 as select col1, col2 from test_bypass_sql_partition limit 10; +execute p_select3; + +prepare p_select4 as select col1, col2 from test_bypass_sql_partition where col1 < $1 and col1 > $2 limit 10; +execute p_select4(20,10); +prepare p_select5 as select col1, col2 from test_bypass_sql_partition where col1 <= $1 and col1 >=$2 limit 10; +execute p_select5(11,15); +--bypass +prepare p_update1 as update test_bypass_sql_partition set col3=$1 where col1=$2; +execute p_update1(1, 10); +prepare p_update2 as update test_bypass_sql_partition set col3=$1,col2=col1-$2 where col1=$3; +execute p_update2('test_null',1,1); +--nobypass +update test_bypass_sql_partition set col3='test_null' where col1 < 70; +update test_bypass_sql_partition set col3='test_null' where true; +update test_bypass_sql_partition set col1 = 1 where col1 > 1 and col1 < 10; +prepare p_update3 as update test_bypass_sql_partition set col1 = $1 where col1 > $2 and col1 < $3; +execute p_update3(1,1,10); + +prepare p_update4 as update test_bypass_sql_partition set col3=$1,col2=mod(5,3) where col1 > $2 and col1 < $3; +execute p_update4('test_null',11,15); +prepare p_update5 as update test_bypass_sql_partition set col3=$1,col2=col1-1 where col1 >= $2 and col1 <= $3; +execute p_update5('test_null',1,10); + +--bypass +prepare p_delete1 as delete from test_bypass_sql_partition where col1=$1; +execute p_delete1 (1); + +--nobypass +prepare p_delete3 as delete from test_bypass_sql_partition where col1 > $1 and col1 < $2; +execute p_delete3(1,10); +prepare p_delete4 as delete from test_bypass_sql_partition where col1 <= $1 and col1 >= $2; +execute p_delete4(1,10); +prepare p_delete2 as delete from test_bypass_sql_partition where true; +execute p_delete2; +reset enable_partition_opfusion; +drop table test_bypass_sql_partition; +