fix err pruningRatio expr and misstake code

This commit is contained in:
gentle_hu
2022-03-17 14:25:09 +08:00
parent f3e27c51bc
commit f5d6b792b3
6 changed files with 68 additions and 66 deletions

View File

@ -302,7 +302,7 @@ void PrepForRead(char* path, int64 blocknum, bool is_segment, RelFileNode *relno
if (NULL != bucketNodestr) {
bucketNodestr += 2; /* delete first two chars: _b */
int _bucketNode;
flag = StrToInt32(bucketNodestr, &_bucketNode); // carrottodo
flag = StrToInt32(bucketNodestr, &_bucketNode);
if (!flag) {
ereport(ERROR, (errmsg("Can not covert %s to int32 type. \n", bucketNodestr)));
}
@ -1642,4 +1642,4 @@ static void checkInstanceType()
ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
(errmsg("Must be in primary DN."))));
}
}
}

View File

@ -932,7 +932,7 @@ static void set_plain_rel_size(PlannerInfo* root, RelOptInfo* rel, RangeTblEntry
if (relation->partMap != NULL && PartitionMapIsRange(relation->partMap)) {
RangePartitionMap *partMmap = (RangePartitionMap *)relation->partMap;
pruningRatio = rel->partItrs / partMmap->rangeElementsNum;
pruningRatio = (double)rel->partItrs / partMmap->rangeElementsNum;
}
heap_close(relation, NoLock);

View File

@ -432,19 +432,17 @@ select count(*) from gpi_index_test as t1 NATURAL inner join gpi_index_test1 t2
(1 row)
explain (costs off) select * from gpi_index_test t1 full join gpi_index_test1 t2 on t1.b >= t2.a where t1.b < 200 and t2.a = 50 and t1.a = 100;
QUERY PLAN
--------------------------------------------------------------------------------------
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
Join Filter: (t1.b >= t2.a)
-> Partition Iterator
Iterations: 1
-> Partitioned Index Scan using gpi_index_test_local_a on gpi_index_test t1
Index Cond: (a = 100)
Filter: (b < 200)
Selected Partitions: 2
-> Index Scan using gpi_index_test1_global_a on gpi_index_test1 t2
Index Cond: (a = 50)
(10 rows)
-> Bitmap Heap Scan on gpi_index_test t1
Recheck Cond: ((b >= t2.a) AND (b < 200))
Filter: (a = 100)
-> Bitmap Index Scan on gpi_index_test_global_b
Index Cond: ((b >= t2.a) AND (b < 200))
(8 rows)
select * from gpi_index_test t1 full join gpi_index_test1 t2 on t1.b >= t2.a where t1.b < 200 and t2.a = 50 and t1.a = 100;
a | b | c | a | b | c
@ -470,15 +468,15 @@ select count(*) from gpi_index_test t1 left join gpi_index_test1 t2 on (t1.b >=
(1 row)
explain (costs off) select * from gpi_index_test t1 right join gpi_index_test1 t2 on (t1.b >= t2.a and (t1.a < 60 or t2.b != 30)) where t1.b < 200 and t2.a < 100;
QUERY PLAN
-----------------------------------------------------------------------------
QUERY PLAN
---------------------------------------------------------------------------
Nested Loop
Join Filter: ((t1.b >= t2.a) AND ((t1.a < 60) OR (t2.b <> 30)))
-> Index Scan using gpi_index_test_global_b on gpi_index_test t1
Index Cond: (b < 200)
-> Index Scan using gpi_index_test1_global_a on gpi_index_test1 t2
Index Cond: (a < 100)
-> Materialize
-> Index Scan using gpi_index_test1_global_a on gpi_index_test1 t2
Index Cond: (a < 100)
-> Index Scan using gpi_index_test_global_b on gpi_index_test t1
Index Cond: (b < 200)
(7 rows)
select count(*) from gpi_index_test t1 left join gpi_index_test1 t2 on (t1.b >= t2.a and (t1.a != 60 or t1.b != 30)) where t1.b < 200 and t2.a < 100;

View File

@ -51,15 +51,19 @@ CREATE INDEX range_list_idx ON range_list(month_code) LOCAL
);
-- test subpartition index scan
explain (costs off) select * from range_list where month_code = '201902';
QUERY PLAN
-------------------------------------------------------
QUERY PLAN
-----------------------------------------------------------------
Partition Iterator
Iterations: 1, Sub Iterations: 2
-> Partitioned Seq Scan on range_list
Filter: ((month_code)::text = '201902'::text)
-> Partitioned Bitmap Heap Scan on range_list
Recheck Cond: ((month_code)::text = '201902'::text)
Selected Partitions: 1
Selected Subpartitions: ALL
(6 rows)
-> Partitioned Bitmap Index Scan on range_list_idx
Index Cond: ((month_code)::text = '201902'::text)
Selected Partitions: 1
Selected Subpartitions: ALL
(10 rows)
select * from range_list where month_code = '201902' order by 1,2,3,4;
month_code | dept_code | user_no | sales_amt

View File

@ -21,10 +21,10 @@ prepare p1(int,int) as SELECT * FROM r INNER JOIN h ON r.a=$1 and h.a=$2;
explain execute p1(10,10);
QUERY PLAN
---------------------------------------------------------------------------------
Nested Loop (cost=0.00..66.27 rows=121 width=16)
-> Partition Iterator (cost=0.00..27.86 rows=11 width=8)
Nested Loop (cost=0.00..67.27 rows=121 width=16)
-> Partition Iterator (cost=0.00..28.86 rows=11 width=8)
Iterations: PART
-> Partitioned Seq Scan on r (cost=0.00..27.86 rows=11 width=8)
-> Partitioned Seq Scan on r (cost=0.00..28.86 rows=11 width=8)
Filter: (a = $1)
Selected Partitions: PART
-> Materialize (cost=0.00..36.92 rows=11 width=8)
@ -45,13 +45,13 @@ prepare p2(int,int,int,int) as select * from r inner join h on r.a=$1 and h.a=$2
explain execute p2(1,1,1,1);
QUERY PLAN
---------------------------------------------------------------------------------------------
Result (cost=0.00..119.80 rows=1331 width=24)
Result (cost=0.00..120.80 rows=1331 width=24)
One-Time Filter: ($1 = $3)
-> Nested Loop (cost=0.00..119.80 rows=1331 width=24)
-> Nested Loop (cost=0.00..66.27 rows=121 width=16)
-> Partition Iterator (cost=0.00..27.86 rows=11 width=8)
-> Nested Loop (cost=0.00..120.80 rows=1331 width=24)
-> Nested Loop (cost=0.00..67.27 rows=121 width=16)
-> Partition Iterator (cost=0.00..28.86 rows=11 width=8)
Iterations: PART
-> Partitioned Seq Scan on r (cost=0.00..27.86 rows=11 width=8)
-> Partitioned Seq Scan on r (cost=0.00..28.86 rows=11 width=8)
Filter: (a = $3)
Selected Partitions: PART
-> Materialize (cost=0.00..36.92 rows=11 width=8)
@ -78,16 +78,16 @@ prepare p3(int,int) as SELECT * FROM r right JOIN h ON r.a=$1 and h.a=$2;
explain execute p3(10,10);
QUERY PLAN
---------------------------------------------------------------------------------
Nested Loop Left Join (cost=0.00..413.97 rows=2149 width=16)
Nested Loop Left Join (cost=0.00..414.97 rows=2149 width=16)
Join Filter: (h.a = $2)
-> Partition Iterator (cost=0.00..31.49 rows=2149 width=8)
Iterations: 2
-> Partitioned Seq Scan on h (cost=0.00..31.49 rows=2149 width=8)
Selected Partitions: 1..2
-> Materialize (cost=0.00..27.92 rows=11 width=8)
-> Partition Iterator (cost=0.00..27.86 rows=11 width=8)
-> Materialize (cost=0.00..28.92 rows=11 width=8)
-> Partition Iterator (cost=0.00..28.86 rows=11 width=8)
Iterations: PART
-> Partitioned Seq Scan on r (cost=0.00..27.86 rows=11 width=8)
-> Partitioned Seq Scan on r (cost=0.00..28.86 rows=11 width=8)
Filter: (a = $1)
Selected Partitions: PART
(12 rows)

View File

@ -1299,9 +1299,9 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Partition Iterator (cost=10000000000.00..1000000000827.00 rows=1 width=8)
Partition Iterator (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.00 rows=1 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Index Cond: ((col1 = 10) AND (col2 = 10))
Selected Partitions: 2
(6 rows)
@ -1316,10 +1316,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..1000000000827.00 rows=1 width=8)
-> Partition Iterator (cost=10000000000.00..1000000000827.00 rows=1 width=8)
Limit (cost=10000000000.00..1000000000827.01 rows=1 width=8)
-> Partition Iterator (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.00 rows=1 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Index Cond: ((col1 = 10) AND (col2 = 10))
Selected Partitions: 2
(7 rows)
@ -1334,10 +1334,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1=10 and col2=1
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..1000000000827.00 rows=1 width=8)
-> Partition Iterator (cost=10000000000.00..1000000000827.00 rows=1 width=8)
Limit (cost=10000000000.00..1000000000827.01 rows=1 width=8)
-> Partition Iterator (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.00 rows=1 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000000827.01 rows=1 width=8)
Index Cond: ((col1 = 10) AND (col2 = 10))
Selected Partitions: 2
(7 rows)
@ -1414,10 +1414,10 @@ explain select col1, col2 from test_bypass_sql_partition where col1 <= 30 and co
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
[No Bypass]reason: Bypass not support query in multiple partitions.
Limit (cost=0.00..24.37 rows=6 width=8)
-> Partition Iterator (cost=0.00..24.37 rows=6 width=8)
Limit (cost=0.00..28.37 rows=6 width=8)
-> Partition Iterator (cost=0.00..28.37 rows=6 width=8)
Iterations: 3
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=0.00..24.37 rows=6 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=0.00..28.37 rows=6 width=8)
Index Cond: ((col1 <= 30) AND (col1 >= 10))
Selected Partitions: 2..4
(7 rows)
@ -1494,10 +1494,10 @@ explain select col1, col2 from test_bypass_sql_partition where col1 < 20 order b
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------
[No Bypass]reason: Bypass not support query in multiple partitions.
Limit (cost=0.00..1.42 rows=10 width=8)
-> Partition Iterator (cost=0.00..55.06 rows=389 width=8)
Limit (cost=0.00..1.83 rows=10 width=8)
-> Partition Iterator (cost=0.00..71.06 rows=389 width=8)
Iterations: 2
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=0.00..55.06 rows=389 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=0.00..71.06 rows=389 width=8)
Index Cond: (col1 < 20)
Selected Partitions: 1..2
(7 rows)
@ -1894,9 +1894,9 @@ explain select col1,col2 from test_bypass_sql_partition where col1=0 order by c
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Partition Iterator (cost=10000000000.00..1000000002435.50 rows=6 width=8)
Partition Iterator (cost=10000000000.00..1000000002435.51 rows=6 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002435.50 rows=6 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002435.51 rows=6 width=8)
Index Cond: (col1 = 0)
Selected Partitions: 1
(6 rows)
@ -1921,10 +1921,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1>0 and col1<10
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..1000000002437.00 rows=6 width=8)
-> Partition Iterator (cost=10000000000.00..1000000002437.00 rows=6 width=8)
Limit (cost=10000000000.00..1000000002437.01 rows=6 width=8)
-> Partition Iterator (cost=10000000000.00..1000000002437.01 rows=6 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002437.00 rows=6 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002437.01 rows=6 width=8)
Index Cond: ((col1 > 0) AND (col1 < 10))
Selected Partitions: 1
(7 rows)
@ -1949,9 +1949,9 @@ explain select col2,col1 from test_bypass_sql_partition where col1>0 and col1<10
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..505000001218.50 rows=3 width=8)
-> Partition Iterator (cost=10000000000.00..1000000002437.00 rows=6 width=8)
-> Partition Iterator (cost=10000000000.00..1000000002437.01 rows=6 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002437.00 rows=6 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000002437.01 rows=6 width=8)
Index Cond: ((col1 > 0) AND (col1 < 10))
Selected Partitions: 1
(7 rows)
@ -1968,10 +1968,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<1
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.50 rows=2 width=8)
Limit (cost=10000000000.00..1000000001234.51 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.51 rows=2 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.51 rows=2 width=8)
Index Cond: ((col1 >= 0) AND (col1 < 10) AND (col2 > 0))
Selected Partitions: 1
(7 rows)
@ -1988,10 +1988,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<1
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[Bypass]
Limit (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.50 rows=2 width=8)
Limit (cost=10000000000.00..1000000001234.51 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.51 rows=2 width=8)
Iterations: 1
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.51 rows=2 width=8)
Index Cond: ((col1 >= 0) AND (col1 < 10) AND (col2 > 0))
Selected Partitions: 1
(7 rows)
@ -2167,10 +2167,10 @@ explain select col1,col2 from test_bypass_sql_partition where col1>=0 and col1<=
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
[No Bypass]reason: Bypass not support query in multiple partitions.
Limit (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.50 rows=2 width=8)
Limit (cost=10000000000.00..1000000001234.52 rows=2 width=8)
-> Partition Iterator (cost=10000000000.00..1000000001234.52 rows=2 width=8)
Iterations: 2
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.50 rows=2 width=8)
-> Partitioned Index Only Scan using itest_bypass_sql_partition on test_bypass_sql_partition (cost=10000000000.00..1000000001234.52 rows=2 width=8)
Index Cond: ((col1 >= 0) AND (col1 <= 10) AND (col2 > 0))
Selected Partitions: 1..2
(7 rows)