update rewrite rules

* adjust re est cost for nestloop semi/anti join

* add threshold for cost base transform
This commit is contained in:
zs
2021-06-16 11:36:24 +08:00
committed by MizuhaHimuraki
parent cbeee6568e
commit 03001c1fe3
6 changed files with 70 additions and 84 deletions

View File

@ -9476,50 +9476,48 @@ Outputs & filters:
SQL: select * from t4,t4 t5 where t4.c1 in (select t7.c1 from t7,t8);
=================================================================
|ID|OPERATOR |NAME |EST. ROWS |COST |
-----------------------------------------------------------------
|0 |NESTED-LOOP JOIN CARTESIAN | |15504908587|11299759339|
|1 | NESTED-LOOP JOIN | |155050 |3869186 |
|2 | TABLE SCAN |t4 |100000 |64066 |
|3 | SUBPLAN SCAN |VIEW2|1 |38 |
|4 | LIMIT | |1 |38 |
|5 | NESTED-LOOP JOIN CARTESIAN| |1 |37 |
|6 | TABLE GET |t7 |1 |36 |
|7 | TABLE SCAN |t8 |100000 |59654 |
|8 | MATERIAL | |100000 |119192 |
|9 | TABLE SCAN |t5 |100000 |64066 |
=================================================================
===============================================================
|ID|OPERATOR |NAME |EST. ROWS |COST |
---------------------------------------------------------------
|0 |NESTED-LOOP JOIN CARTESIAN | |9900000000|7216269494|
|1 | TABLE SCAN |t5 |100000 |64066 |
|2 | MATERIAL | |99000 |3771257 |
|3 | NESTED-LOOP SEMI JOIN | |99000 |3716682 |
|4 | TABLE SCAN |t4 |100000 |64066 |
|5 | SUBPLAN SCAN |VIEW1|1 |36 |
|6 | NESTED-LOOP JOIN CARTESIAN| |1 |36 |
|7 | TABLE GET |t7 |1 |36 |
|8 | TABLE SCAN |t8 |100000 |59654 |
===============================================================
Outputs & filters:
-------------------------------------
0 - output([t4.c1], [t4.c2], [t4.c3], [t5.c1], [t5.c2], [t5.c3]), filter(nil),
conds(nil), nl_params_(nil), batch_join=false
1 - output([t4.c1], [t4.c2], [t4.c3]), filter(nil),
1 - output([t5.c1], [t5.c2], [t5.c3]), filter(nil),
access([t5.c1], [t5.c2], [t5.c3]), partitions(p0),
is_index_back=false,
range_key([t5.c1], [t5.c2]), range(MIN,MIN ; MAX,MAX)always true
2 - output([t4.c1], [t4.c2], [t4.c3]), filter(nil)
3 - output([t4.c1], [t4.c2], [t4.c3]), filter(nil),
conds(nil), nl_params_([t4.c1]), batch_join=false
2 - output([t4.c1], [t4.c2], [t4.c3]), filter(nil),
4 - output([t4.c1], [t4.c2], [t4.c3]), filter(nil),
access([t4.c1], [t4.c2], [t4.c3]), partitions(p0),
is_index_back=false,
range_key([t4.c1], [t4.c2]), range(MIN,MIN ; MAX,MAX)always true
3 - output([1]), filter(nil),
access([VIEW2.VIEW1.c1])
4 - output([t7.c1]), filter(nil), limit(1), offset(nil)
5 - output([t7.c1]), filter(nil),
conds(nil), nl_params_(nil), batch_join=true
5 - output([1]), filter(nil),
access([VIEW1.c1])
6 - output([t7.c1]), filter(nil),
conds(nil), nl_params_(nil), batch_join=true
7 - output([t7.c1]), filter(nil),
access([t7.c1]), partitions(p0),
is_index_back=false,
range_key([t7.c1]), range(MIN ; MAX)always true,
range_cond([? = t7.c1])
7 - output([1]), filter(nil),
8 - output([1]), filter(nil),
access([t8.c1]), partitions(p0),
is_index_back=false,
range_key([t8.c1]), range(MIN ; MAX)always true
8 - output([t5.c1], [t5.c2], [t5.c3]), filter(nil)
9 - output([t5.c1], [t5.c2], [t5.c3]), filter(nil),
access([t5.c1], [t5.c2], [t5.c3]), partitions(p0),
is_index_back=false,
range_key([t5.c1], [t5.c2]), range(MIN,MIN ; MAX,MAX)always true
*************** Case 273(end) **************

View File

@ -3003,17 +3003,15 @@ SQL: select t20.c1 from t20 join t0 where t0.c1 in (select t7.c1 from t7 join t8
========================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
--------------------------------------------------------
|0 |NESTED-LOOP JOIN CARTESIAN | |10000 |17490|
|1 | MERGE SEMI JOIN | |100 |10301|
|2 | SORT | |100 |198 |
|3 | TABLE SCAN |t0 |100 |90 |
|4 | SUBPLAN SCAN |VIEW1|10000 |8650 |
|5 | NESTED-LOOP JOIN CARTESIAN| |10000 |7270 |
|6 | TABLE SCAN |t7 |100 |88 |
|7 | MATERIAL | |100 |106 |
|8 | TABLE SCAN |t8 |100 |88 |
|9 | MATERIAL | |100 |113 |
|10| TABLE SCAN |t20 |100 |95 |
|0 |NESTED-LOOP JOIN CARTESIAN | |10000 |10934|
|1 | NESTED-LOOP SEMI JOIN | |100 |3745 |
|2 | TABLE SCAN |t0 |100 |90 |
|3 | SUBPLAN SCAN |VIEW1|1 |36 |
|4 | NESTED-LOOP JOIN CARTESIAN| |1 |36 |
|5 | TABLE GET |t7 |1 |36 |
|6 | TABLE SCAN |t8 |100 |88 |
|7 | MATERIAL | |100 |113 |
|8 | TABLE SCAN |t20 |100 |95 |
========================================================
Outputs & filters:
@ -3021,21 +3019,19 @@ Outputs & filters:
0 - output([t20.c1]), filter(nil),
conds(nil), nl_params_(nil)
1 - output([1]), filter(nil),
equal_conds([t0.c1 = VIEW1.c1]), other_conds(nil)
2 - output([t0.c1]), filter(nil), sort_keys([t0.c1, ASC])
3 - output([t0.c1]), filter(nil),
conds(nil), nl_params_([t0.c1])
2 - output([t0.c1]), filter(nil),
access([t0.c1]), partitions(p0)
4 - output([VIEW1.c1]), filter(nil),
3 - output([1]), filter(nil),
access([VIEW1.c1])
5 - output([t7.c1]), filter(nil),
4 - output([t7.c1]), filter(nil),
conds(nil), nl_params_(nil)
6 - output([t7.c1]), filter(nil),
5 - output([t7.c1]), filter(nil),
access([t7.c1]), partitions(p0)
7 - output([1]), filter(nil)
8 - output([1]), filter(nil),
6 - output([1]), filter(nil),
access([t8.c1]), partitions(p0)
9 - output([t20.c1]), filter(nil)
10 - output([t20.c1]), filter(nil),
7 - output([t20.c1]), filter(nil)
8 - output([t20.c1]), filter(nil),
access([t20.c1]), partitions(p0)
Outline Data:
@ -3045,11 +3041,12 @@ Outline Data:
LEADING(@"SEL$1" (("opt.t0"@"SEL$1" "VIEW1"@"SEL$1" )"opt.t20"@"SEL$1" ))
USE_NL(@"SEL$1" ("opt.t20"@"SEL$1" ))
USE_NL_MATERIALIZATION(@"SEL$1" ("opt.t20"@"SEL$1" ))
USE_MERGE(@"SEL$1" ("VIEW1"@"SEL$1" ))
USE_NL(@"SEL$1" ("VIEW1"@"SEL$1" ))
NO_USE_NL_MATERIALIZATION(@"SEL$1" ("VIEW1"@"SEL$1" ))
FULL(@"SEL$1" "opt.t0"@"SEL$1")
LEADING(@"SEL$2" ("opt.t7"@"SEL$2" "opt.t8"@"SEL$2" ))
USE_NL(@"SEL$2" ("opt.t8"@"SEL$2" ))
USE_NL_MATERIALIZATION(@"SEL$2" ("opt.t8"@"SEL$2" ))
NO_USE_NL_MATERIALIZATION(@"SEL$2" ("opt.t8"@"SEL$2" ))
FULL(@"SEL$2" "opt.t7"@"SEL$2")
FULL(@"SEL$2" "opt.t8"@"SEL$2")
FULL(@"SEL$1" "opt.t20"@"SEL$1")

View File

@ -2472,34 +2472,30 @@ Outline Data:
*************** Case 77 ***************
SQL: SELECT c1 FROM pullup1 WHERE c1 IN (SELECT pullup2.pk FROM pullup2, pullup3);
===============================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
---------------------------------------------------------------
|0 |MERGE SEMI JOIN | |100 |10265|
|1 | SORT | |100 |198 |
|2 | TABLE SCAN |pullup1 |100 |90 |
|3 | SUBPLAN SCAN |VIEW1 |10000 |8615 |
|4 | NESTED-LOOP JOIN CARTESIAN| |10000 |7235 |
|5 | TABLE SCAN |pullup2 |100 |88 |
|6 | MATERIAL | |100 |71 |
|7 | TABLE SCAN |pullup3(uniq)|100 |52 |
===============================================================
==============================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
--------------------------------------------------------------
|0 |NESTED-LOOP SEMI JOIN | |100 |3745|
|1 | TABLE SCAN |pullup1 |100 |90 |
|2 | SUBPLAN SCAN |VIEW1 |1 |36 |
|3 | NESTED-LOOP JOIN CARTESIAN| |1 |36 |
|4 | TABLE GET |pullup2 |1 |36 |
|5 | TABLE SCAN |pullup3(uniq)|100 |52 |
==============================================================
Outputs & filters:
-------------------------------------
0 - output([pullup1.c1]), filter(nil),
equal_conds([pullup1.c1 = VIEW1.pk]), other_conds(nil)
1 - output([pullup1.c1]), filter(nil), sort_keys([pullup1.c1, ASC])
2 - output([pullup1.c1]), filter(nil),
conds(nil), nl_params_([pullup1.c1])
1 - output([pullup1.c1]), filter(nil),
access([pullup1.c1]), partitions(p0)
3 - output([VIEW1.pk]), filter(nil),
2 - output([1]), filter(nil),
access([VIEW1.pk])
4 - output([pullup2.pk]), filter(nil),
3 - output([pullup2.pk]), filter(nil),
conds(nil), nl_params_(nil)
5 - output([pullup2.pk]), filter(nil),
4 - output([pullup2.pk]), filter(nil),
access([pullup2.pk]), partitions(p0)
6 - output([1]), filter(nil)
7 - output([1]), filter(nil),
5 - output([1]), filter(nil),
access([pullup3.uniq_c2]), partitions(p0)
Outline Data:
@ -2507,11 +2503,12 @@ Outline Data:
/*+
BEGIN_OUTLINE_DATA
LEADING(@"SEL$1" ("opt.pullup1"@"SEL$1" "VIEW1"@"SEL$1" ))
USE_MERGE(@"SEL$1" ("VIEW1"@"SEL$1" ))
USE_NL(@"SEL$1" ("VIEW1"@"SEL$1" ))
NO_USE_NL_MATERIALIZATION(@"SEL$1" ("VIEW1"@"SEL$1" ))
FULL(@"SEL$1" "opt.pullup1"@"SEL$1")
LEADING(@"SEL$2" ("opt.pullup2"@"SEL$2" "opt.pullup3"@"SEL$2" ))
USE_NL(@"SEL$2" ("opt.pullup3"@"SEL$2" ))
USE_NL_MATERIALIZATION(@"SEL$2" ("opt.pullup3"@"SEL$2" ))
NO_USE_NL_MATERIALIZATION(@"SEL$2" ("opt.pullup3"@"SEL$2" ))
FULL(@"SEL$2" "opt.pullup2"@"SEL$2")
INDEX(@"SEL$2" "opt.pullup3"@"SEL$2" "uniq")
END_OUTLINE_DATA