From 3c1b7fb03e35c4685f797f9ca410e15ae20c62cd Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 12 Feb 2023 14:53:47 +0200 Subject: [PATCH] Adjust costs for rowid filter - Use log2() insted of log() - Added missing ''+' when calculating rowid setup cost - Adjusted ROWID_FILTER_PER_ELEMENT_MODIFIER (from 3 to 1) Other things: - Adjusted cost for index_merge where rows_out < 1.0 The effects of the changes: - rowid filter will have higher setup cost - rowid filter will have slightly less costs per row This can be seen in mtr where some tests, with 'small tables or that uses rowid filters with many rows, will not use rowid filter anymore. --- .../include/rowid_filter_debug_kill.inc | 13 +- mysql-test/main/index_merge_myisam.result | 2 +- mysql-test/main/join_nested_jcl6.result | 2 +- mysql-test/main/opt_trace.result | 46 +-- mysql-test/main/opt_trace_index_merge.result | 26 +- .../main/opt_trace_index_merge_innodb.result | 2 +- .../main/partition_explicit_prune.result | 2 +- mysql-test/main/partition_pruning.result | 2 +- mysql-test/main/range.result | 12 +- mysql-test/main/range_innodb.result | 2 +- mysql-test/main/range_vs_index_merge.result | 2 +- mysql-test/main/rowid_filter.result | 351 +++++++----------- mysql-test/main/rowid_filter.test | 8 +- mysql-test/main/rowid_filter_aria.result | 266 ++++--------- mysql-test/main/rowid_filter_innodb.result | 307 ++++++--------- mysql-test/main/rowid_filter_innodb.test | 1 + .../main/rowid_filter_innodb_debug.result | 12 +- mysql-test/main/rowid_filter_myisam.result | 40 +- .../main/rowid_filter_myisam_debug.result | 12 +- mysql-test/main/select.result | 12 +- mysql-test/main/select_jcl6.result | 12 +- mysql-test/main/select_pkeycache.result | 12 +- mysql-test/main/selectivity.result | 4 +- mysql-test/main/selectivity_innodb.result | 4 +- mysql-test/main/stat_tables.result | 2 +- mysql-test/main/stat_tables.test | 1 - mysql-test/main/subselect_sj2.result | 2 +- mysql-test/main/subselect_sj2_jcl6.result | 2 +- mysql-test/main/subselect_sj2_mat.result | 2 +- mysql-test/suite/maria/icp.result | 2 +- sql/opt_range.cc | 13 +- sql/optimizer_defaults.h | 2 +- sql/rowid_filter.cc | 8 +- 33 files changed, 438 insertions(+), 748 deletions(-) diff --git a/mysql-test/include/rowid_filter_debug_kill.inc b/mysql-test/include/rowid_filter_debug_kill.inc index c672954fc7c..230bef6d10c 100644 --- a/mysql-test/include/rowid_filter_debug_kill.inc +++ b/mysql-test/include/rowid_filter_debug_kill.inc @@ -9,9 +9,6 @@ --echo # MDEV-22761 KILL QUERY during rowid_filter, crashes --echo # -create table t1(a int); -insert into t1 select seq from seq_1_to_1000; - create table t2(a int); insert into t2 select seq from seq_1_to_100; @@ -30,17 +27,17 @@ where table_schema=database() and table_name='t3'; analyze table t2,t3; explain -select * from t2, t3 +select straight_join * from t2, t3 where - t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); + t3.key1=t2.a and t3.key2 between 2 and 10; let $target_id= `select connection_id()`; set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; send -select * from t2, t3 +select straight_join * from t2, t3 where - t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); + t3.key1=t2.a and t3.key2 between 2 and 10; connect (con1, localhost, root,,); set debug_sync='now WAIT_FOR at_rowid_filter_check'; @@ -54,5 +51,5 @@ disconnect con1; reap; set debug_sync='RESET'; -drop table t1,t2,t3; +drop table t2,t3; --source include/wait_until_count_sessions.inc diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result index 2c84086d17d..5866612c186 100644 --- a/mysql-test/main/index_merge_myisam.result +++ b/mysql-test/main/index_merge_myisam.result @@ -1558,7 +1558,7 @@ This should be intersect: set optimizer_switch=default; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter a,b a|b 5|5 const 49 (1%) Using where; Using rowid filter +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where No intersect when index_merge is disabled: set optimizer_switch='default,index_merge=off,rowid_filter=off'; explain select * from t1 where a=10 and b=10; diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 2148fb859b4..d5c46d48e68 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -2086,7 +2086,7 @@ ON t6.b >= 2 AND t5.b=t7.b AND id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 1 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter -1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using rowid filter +1 SIMPLE t6 range PRIMARY,b_i PRIMARY 4 NULL 3 Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref b_i b_i 5 test.t5.b 1 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 3571b4ac978..b28c342fd96 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -2380,12 +2380,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { "rowid_filters": [ { "key": "a_b", - "build_cost": 6.9153e-4, + "build_cost": 0.005839142, "rows": 41 }, { "key": "a_c", - "build_cost": 0.0040552, + "build_cost": 0.024214742, "rows": 180 } ] @@ -3832,17 +3832,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { "rowid_filters": [ { "key": "pk", - "build_cost": 0.000002653, + "build_cost": 0.000899465, "rows": 1 }, { "key": "pk_a", - "build_cost": 0.000002653, + "build_cost": 0.000899465, "rows": 1 }, { "key": "pk_a_b", - "build_cost": 0.000002653, + "build_cost": 0.000899465, "rows": 1 } ] @@ -12277,12 +12277,12 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rowid_filters": [ { "key": "a", - "build_cost": 9.95653e-5, + "build_cost": 0.001846537, "rows": 9 }, { "key": "b", - "build_cost": 3.004222e-4, + "build_cost": 0.003322634, "rows": 21 } ] @@ -12325,17 +12325,17 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "filter": { "rowid_filter_index": "b", "index_only_cost": 0.001605807, - "filter_startup_cost": 3.004222e-4, - "find_key_and_filter_lookup_cost": 7.827422e-4, + "filter_startup_cost": 0.003322634, + "find_key_and_filter_lookup_cost": 6.695354e-4, "filter_selectivity": 0.021, "original_rows": 9, "new_rows": 0.189, "original_access_cost": 0.011607363, - "with_filter_access_cost": 0.002598582, + "with_filter_access_cost": 0.002485375, "original_found_rows_cost": 0.010001556, "with_filter_found_rows_cost": 2.100327e-4, "org_cost": 0.011895363, - "filter_cost": 0.002905052, + "filter_cost": 0.005814057, "filter_used": true }, "access_type": "range", @@ -12343,7 +12343,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "rows": 9, "rows_after_filter": 0.189, "rows_out": 0.017766, - "cost": 0.002905052, + "cost": 0.005814057, "chosen": true } ], @@ -12351,7 +12351,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "type": "range", "rows_read": 0.189, "rows_out": 0.017766, - "cost": 0.002905052, + "cost": 0.005814057, "uses_join_buffering": false, "rowid_filter_index": "b" } @@ -12363,7 +12363,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { "plan_prefix": "", "table": "t1", "rows_for_plan": 0.017766, - "cost_for_plan": 0.002905052, + "cost_for_plan": 0.005814057, "pushdown_cond_selectivity": 0.094, "filtered": 0.1974, "rows_out": 0.017766 @@ -12373,7 +12373,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { { "best_join_order": ["t1"], "rows": 0.017766, - "cost": 0.002905052 + "cost": 0.005814057 }, { "table": "t1", @@ -12470,7 +12470,7 @@ EXPLAIN { "query_block": { "select_id": 1, - "cost": 2.303362315, + "cost": 2.662022424, "nested_loop": [ { "table": { @@ -12502,7 +12502,7 @@ EXPLAIN }, "loops": 3, "rows": 1000, - "cost": 2.2928575, + "cost": 2.651517609, "filtered": 43.11999893, "attached_condition": "t1.b < 5000 and t1.c < 1000" } @@ -12673,7 +12673,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "rowid_filters": [ { "key": "b", - "build_cost": 0.149564727, + "build_cost": 0.611957109, "rows": 4312 } ] @@ -12779,21 +12779,21 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and "filter": { "rowid_filter_index": "b", "index_only_cost": 0.092096742, - "filter_startup_cost": 0.149564727, - "find_key_and_filter_lookup_cost": 0.129350121, + "filter_startup_cost": 0.611957109, + "find_key_and_filter_lookup_cost": 0.094772697, "filter_selectivity": 0.4312, "original_rows": 1000, "new_rows": 431.2, "original_access_cost": 1.203380742, - "with_filter_access_cost": 0.700632524, + "with_filter_access_cost": 0.6660551, "original_found_rows_cost": 1.111284, "with_filter_found_rows_cost": 0.479185661, "org_cost": 3.706142226, - "filter_cost": 2.2928575, + "filter_cost": 2.651517609, "filter_used": true }, "rows": 431.2, - "cost": 2.2928575, + "cost": 2.651517609, "chosen": true }, { diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index 5f111e4836e..994e6e88452 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -394,8 +394,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "index": "key2", "index_scan_cost": 0.240986767, "cumulated_index_scan_cost": 0.481973534, - "disk_sweep_cost": 0.088032868, - "cumulative_total_cost": 0.570006402, + "disk_sweep_cost": 0.089164506, + "cumulative_total_cost": 0.57113804, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -420,7 +420,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "chosen": true }, @@ -436,7 +436,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -458,7 +458,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ] }, "rows_for_plan": 77, - "cost_for_plan": 0.572490756, + "cost_for_plan": 0.573622393, "chosen": true } ] @@ -572,8 +572,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "index": "key2", "index_scan_cost": 0.240986767, "cumulated_index_scan_cost": 0.481973534, - "disk_sweep_cost": 0.088032868, - "cumulative_total_cost": 0.570006402, + "disk_sweep_cost": 0.089164506, + "cumulative_total_cost": 0.57113804, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -586,7 +586,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "chosen": true } @@ -616,8 +616,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "index": "key4", "index_scan_cost": 0.240986767, "cumulated_index_scan_cost": 0.481973534, - "disk_sweep_cost": 0.088032868, - "cumulative_total_cost": 0.570006402, + "disk_sweep_cost": 0.089164506, + "cumulative_total_cost": 0.57113804, "usable": true, "matching_rows_now": 77.6360508, "intersect_covering_with_this_index": false, @@ -630,7 +630,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) "cause": "no clustered pk index" }, "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "chosen": true } @@ -655,7 +655,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "clustered_pk_scan": false, "intersect_of": @@ -679,7 +679,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) { "type": "index_roworder_intersect", "rows": 77, - "cost": 0.572490756, + "cost": 0.573622393, "covering": false, "clustered_pk_scan": false, "intersect_of": diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 635301b0d18..02509aa9610 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -178,7 +178,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { "rowid_filters": [ { "key": "key1", - "build_cost": 0.000002653, + "build_cost": 0.001763258, "rows": 1 } ] diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result index 20a3d5bb8c0..f4436c5040c 100644 --- a/mysql-test/main/partition_explicit_prune.result +++ b/mysql-test/main/partition_explicit_prune.result @@ -1937,7 +1937,7 @@ MOD(seq, 100), seq_1_to_5000; explain select * from t1 partition (p1) where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter a,b a|b 5|5 const 49 (1%) Using where; Using rowid filter +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where flush tables; select * from t1 partition (p1)where a=10 and b=10; pk a b filler diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result index 6834cf0e657..eef1df4095f 100644 --- a/mysql-test/main/partition_pruning.result +++ b/mysql-test/main/partition_pruning.result @@ -2677,7 +2677,7 @@ select * from t1 X, t1 Y where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where -1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 1 (50%) Using where; Using rowid filter +1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 1 Using where explain partitions select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); id select_type table partitions type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 6d9f2d8b1c3..a352252c616 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -281,7 +281,7 @@ INSERT INTO t1 VALUES (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter a,b a|b 5|5 NULL 2 (41%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 range a,b a 5 NULL 2 Using index condition; Using where SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; @@ -2563,7 +2563,7 @@ insert into t2 values explain select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 3 (60%) Using index condition; Using where; Using rowid filter +1 SIMPLE t2 range idx1,idx2 idx1 5 NULL 3 Using index condition; Using where 1 SIMPLE t1 ref idx idx 5 test.t2.d 8 explain format=json select * from t1,t2 where a = d and (a,e) in ((3,3),(7,7),(2,2)); @@ -2581,14 +2581,6 @@ EXPLAIN "key": "idx1", "key_length": "5", "used_key_parts": ["d"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["e"] - }, - "rows": 12, - "selectivity_pct": 60 - }, "loops": 1, "rows": 3, "cost": "COST_REPLACED", diff --git a/mysql-test/main/range_innodb.result b/mysql-test/main/range_innodb.result index 826c0e4d90a..542d0eed294 100644 --- a/mysql-test/main/range_innodb.result +++ b/mysql-test/main/range_innodb.result @@ -98,7 +98,7 @@ SET @saved_dbug = @@GLOBAL.debug_dbug; set @@global.debug_dbug="+d,ha_index_init_fail"; explain select * from t1 where a=10 and b=10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter a,b a|b 5|5 const 50 (2%) Using where; Using rowid filter +1 SIMPLE t1 index_merge a,b a,b 5,5 NULL 1 Using intersect(a,b); Using where select * from t1 where a=10 and b=10; ERROR HY000: Table definition has changed, please retry transaction DROP TABLE t0,t1; diff --git a/mysql-test/main/range_vs_index_merge.result b/mysql-test/main/range_vs_index_merge.result index 19848d6d388..03ae3d69507 100644 --- a/mysql-test/main/range_vs_index_merge.result +++ b/mysql-test/main/range_vs_index_merge.result @@ -949,7 +949,7 @@ WHERE ((Population > 101000 AND Population < 11000) OR ID BETWEEN 3500 AND 3800) AND Country='USA' AND (Name LIKE 'P%' OR ID BETWEEN 4000 AND 4300); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE City range|filter PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName|PRIMARY 38|4 NULL 23 (7%) Using index condition; Using where; Using rowid filter +1 SIMPLE City range PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName 38 NULL 23 Using index condition; Using where EXPLAIN SELECT * FROM City WHERE ((Population > 101000 AND Population < 11000) OR diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result index 2312fb593d1..1a755e86c74 100644 --- a/mysql-test/main/rowid_filter.result +++ b/mysql-test/main/rowid_filter.result @@ -57,22 +57,22 @@ set optimizer_use_condition_selectivity=2; select 100 * (select count(*) from lineitem -WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 ) / (select count(*) from lineitem where l_shipdate BETWEEN '1997-01-01' AND '1997-06-30') as correct_r_filtered_when_using_l_shipdate; correct_r_filtered_when_using_l_shipdate -11.7647 +6.6667 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 426 (8%) Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -84,23 +84,23 @@ EXPLAIN "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 702, - "selectivity_pct": 11.69025812 + "rows": 509, + "selectivity_pct": 8.476269775 }, "loops": 1, - "rows": 509, + "rows": 426, "cost": "COST_REPLACED", - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -108,12 +108,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) 60.00 (11%) 11.69 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 426 (8%) 34.00 (9%) 8.48 100.00 Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -130,33 +130,33 @@ ANALYZE "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 702, - "selectivity_pct": 11.69025812, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "rows": 509, + "selectivity_pct": 8.476269775, + "r_rows": 510, + "r_lookups": 349, + "r_selectivity_pct": 9.742120344, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, - "rows": 509, - "r_rows": 60, + "rows": 426, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, + "filtered": 8.476269722, "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -164,21 +164,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -191,49 +183,31 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_quantity 9 NULL 426 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -245,15 +219,15 @@ EXPLAIN "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, - "rows": 509, + "rows": 426, "cost": "COST_REPLACED", - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -261,12 +235,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_quantity 9 NULL 426 349.00 8.48 9.74 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -283,20 +257,20 @@ ANALYZE "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, "r_loops": 1, - "rows": 509, - "r_rows": 510, + "rows": 426, + "r_rows": 349, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "r_filtered": 9.742120344, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -304,21 +278,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -331,41 +297,23 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -676,15 +624,15 @@ o_orderkey l_linenumber l_shipdate o_totalprice set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 426 (8%) Using index condition; Using where; Using rowid filter 1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -703,23 +651,23 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 702, - "selectivity_pct": 11.69025812 + "rows": 509, + "selectivity_pct": 8.476269775 }, "loops": 1, - "rows": 509, + "rows": 426, "cost": "COST_REPLACED", - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -739,7 +687,7 @@ EXPLAIN "rows": 139, "selectivity_pct": 9.266666667 }, - "loops": 59.50341382, + "loops": 36.10890924, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.266666412, @@ -752,15 +700,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) 60.00 (11%) 11.69 100.00 Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) 0.27 (25%) 9.27 100.00 Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 426 (8%) 34.00 (9%) 8.48 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) 0.26 (26%) 9.27 100.00 Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -784,33 +732,33 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 702, - "selectivity_pct": 11.69025812, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "rows": 509, + "selectivity_pct": 8.476269775, + "r_rows": 510, + "r_lookups": 349, + "r_selectivity_pct": 9.742120344, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, - "rows": 509, - "r_rows": 60, + "rows": 426, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, + "filtered": 8.476269722, "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -830,15 +778,15 @@ ANALYZE "rows": 139, "selectivity_pct": 9.266666667, "r_rows": 144, - "r_lookups": 59, - "r_selectivity_pct": 25.42372881, + "r_lookups": 34, + "r_selectivity_pct": 26.47058824, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, - "loops": 59.50341382, - "r_loops": 60, + "loops": 36.10890924, + "r_loops": 34, "rows": 1, - "r_rows": 0.266666667, + "r_rows": 0.264705882, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", @@ -853,37 +801,30 @@ ANALYZE set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity 9 NULL 426 Using index condition; Using where 1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -902,15 +843,15 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, - "rows": 509, + "rows": 426, "cost": "COST_REPLACED", - "filtered": 11.69025803, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -922,7 +863,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 59.50341382, + "loops": 36.10890924, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.266666412, @@ -935,15 +876,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.67 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity 9 NULL 426 349.00 8.48 9.74 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.47 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -967,20 +908,20 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, "r_loops": 1, - "rows": 509, - "r_rows": 510, + "rows": 426, + "r_rows": 349, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 11.69025803, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.476269722, + "r_filtered": 9.742120344, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -992,15 +933,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 59.50341382, - "r_loops": 60, + "loops": 36.10890924, + "r_loops": 34, "rows": 1, "r_rows": 1, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.266666412, - "r_filtered": 26.66666667, + "r_filtered": 26.47058824, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -1010,32 +951,25 @@ ANALYZE set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT STRAIGHT_JOIN o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM lineitem JOIN orders ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 426 (8%) Using index condition; Using where; Using rowid filter 1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey @@ -1712,7 +1646,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1755,14 +1689,6 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 183, - "selectivity_pct": 3.04746045 - }, "loops": 1.248, "rows": 4, "cost": "COST_REPLACED", @@ -1781,7 +1707,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 3.05 100.00 Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1834,28 +1760,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 183, - "selectivity_pct": 3.04746045, - "r_rows": 183, - "r_lookups": 6, - "r_selectivity_pct": 66.66666667, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "loops": 1.248, "r_loops": 1, "rows": 4, - "r_rows": 4, + "r_rows": 6, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 3.047460556, - "r_filtered": 100, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test index bbf0334fbbf..c582a40523a 100644 --- a/mysql-test/main/rowid_filter.test +++ b/mysql-test/main/rowid_filter.test @@ -42,7 +42,7 @@ set statement optimizer_switch='rowid_filter=off' for; select 100 * (select count(*) from lineitem - WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 + WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 ) / (select count(*) from lineitem @@ -52,7 +52,7 @@ select let $q1= SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND - l_quantity > 45; + l_quantity > 47; eval $with_filter EXPLAIN $q1; --source include/explain-no-costs.inc @@ -100,7 +100,7 @@ let $q3= SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND - l_quantity > 45 AND + l_quantity > 47 AND o_totalprice between 180000 and 230000; eval $with_filter EXPLAIN $q3; @@ -125,7 +125,7 @@ eval $without_filter $q3; eval $with_filter EXPLAIN SELECT STRAIGHT_JOIN o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM lineitem JOIN orders ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND - l_quantity > 45 AND + l_quantity > 47 AND o_totalprice between 180000 and 230000; let $q4= diff --git a/mysql-test/main/rowid_filter_aria.result b/mysql-test/main/rowid_filter_aria.result index 2478e787a6d..6ddd2c0679f 100644 --- a/mysql-test/main/rowid_filter_aria.result +++ b/mysql-test/main/rowid_filter_aria.result @@ -58,22 +58,22 @@ set optimizer_use_condition_selectivity=2; select 100 * (select count(*) from lineitem -WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 ) / (select count(*) from lineitem where l_shipdate BETWEEN '1997-01-01' AND '1997-06-30') as correct_r_filtered_when_using_l_shipdate; correct_r_filtered_when_using_l_shipdate -11.7647 +6.6667 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (12%) Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -93,15 +93,15 @@ EXPLAIN "key": "i_l_quantity", "used_key_parts": ["l_quantity"] }, - "rows": 949, - "selectivity_pct": 15.80349709 + "rows": 709, + "selectivity_pct": 11.80682764 }, "loops": 1, "rows": 482, "cost": "COST_REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } } ] @@ -109,12 +109,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) 60.00 (11%) 15.80 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (12%) 34.00 (6%) 11.81 100.00 Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -139,25 +139,25 @@ ANALYZE "key": "i_l_quantity", "used_key_parts": ["l_quantity"] }, - "rows": 949, - "selectivity_pct": 15.80349709, - "r_rows": 605, + "rows": 709, + "selectivity_pct": 11.80682764, + "r_rows": 349, "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "r_selectivity_pct": 6.666666667, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, "rows": 482, - "r_rows": 60, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } } ] @@ -165,21 +165,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -192,49 +184,31 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 482 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -252,9 +226,9 @@ EXPLAIN "loops": 1, "rows": 482, "cost": "COST_REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } } ] @@ -262,12 +236,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 482 510.00 15.80 11.76 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 482 510.00 11.81 6.67 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -294,10 +268,10 @@ ANALYZE "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 15.80349731, - "r_filtered": 11.76470588, + "filtered": 11.80682755, + "r_filtered": 6.666666667, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } } ] @@ -305,21 +279,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -332,41 +298,23 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -677,15 +625,15 @@ o_orderkey l_linenumber l_shipdate o_totalprice set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -712,15 +660,15 @@ EXPLAIN "key": "i_l_quantity", "used_key_parts": ["l_quantity"] }, - "rows": 949, - "selectivity_pct": 15.80349709 + "rows": 709, + "selectivity_pct": 11.80682764 }, "loops": 1, "rows": 482, "cost": "COST_REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } }, { @@ -732,15 +680,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 216, - "selectivity_pct": 14.4 - }, - "loops": 76.17285595, + "loops": 56.90890924, "rows": 1, "cost": "COST_REPLACED", "filtered": 14.39999962, @@ -753,15 +693,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) 60.00 (11%) 15.80 100.00 Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) 0.27 (25%) 14.40 100.00 Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (12%) 34.00 (6%) 11.81 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 14.40 26.47 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -793,25 +733,25 @@ ANALYZE "key": "i_l_quantity", "used_key_parts": ["l_quantity"] }, - "rows": 949, - "selectivity_pct": 15.80349709, - "r_rows": 605, + "rows": 709, + "selectivity_pct": 11.80682764, + "r_rows": 349, "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "r_selectivity_pct": 6.666666667, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, "rows": 482, - "r_rows": 60, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "r_filtered": 100, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } }, { @@ -823,28 +763,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "rowid_filter": { - "range": { - "key": "i_o_totalprice", - "used_key_parts": ["o_totalprice"] - }, - "rows": 216, - "selectivity_pct": 14.4, - "r_rows": 144, - "r_lookups": 59, - "r_selectivity_pct": 25.42372881, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, - "loops": 76.17285595, - "r_loops": 60, + "loops": 56.90890924, + "r_loops": 34, "rows": 1, - "r_rows": 0.266666667, + "r_rows": 1, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.39999962, - "r_filtered": 100, + "r_filtered": 26.47058824, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -854,29 +781,22 @@ ANALYZE set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 482 Using index condition; Using where @@ -884,7 +804,7 @@ id select_type table type possible_keys key key_len ref rows Extra set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -909,9 +829,9 @@ EXPLAIN "loops": 1, "rows": 482, "cost": "COST_REPLACED", - "filtered": 15.80349731, + "filtered": 11.80682755, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } }, { @@ -923,7 +843,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 76.17285595, + "loops": 56.90890924, "rows": 1, "cost": "COST_REPLACED", "filtered": 14.39999962, @@ -936,15 +856,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 482 510.00 15.80 11.76 Using index condition; Using where -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 14.40 26.67 Using where +1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 482 510.00 11.81 6.67 Using index condition; Using where +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 14.40 26.47 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -978,10 +898,10 @@ ANALYZE "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 15.80349731, - "r_filtered": 11.76470588, + "filtered": 11.80682755, + "r_filtered": 6.666666667, "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "attached_condition": "lineitem.l_quantity > 47" } }, { @@ -993,15 +913,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 76.17285595, - "r_loops": 60, + "loops": 56.90890924, + "r_loops": 34, "rows": 1, "r_rows": 1, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 14.39999962, - "r_filtered": 26.66666667, + "r_filtered": 26.47058824, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -1011,33 +931,26 @@ ANALYZE set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT STRAIGHT_JOIN o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM lineitem JOIN orders ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (16%) Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (14%) Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 482 (12%) Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND @@ -1713,7 +1626,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1756,14 +1669,6 @@ EXPLAIN "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 174, - "selectivity_pct": 2.897585346 - }, "loops": 3.05, "rows": 4, "cost": "COST_REPLACED", @@ -1782,7 +1687,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND l_shipdate BETWEEN '1996-10-01' AND '1996-12-01'; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 61 41.00 5.00 2.44 Using index condition; Using where -1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 2.90 100.00 Using where; Using rowid filter +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 2.90 66.67 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate FROM orders, lineitem WHERE o_orderkey=l_orderkey AND @@ -1835,28 +1740,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["l_orderkey"], "ref": ["dbt3_s001.orders.o_orderkey"], - "rowid_filter": { - "range": { - "key": "i_l_shipdate", - "used_key_parts": ["l_shipDATE"] - }, - "rows": 174, - "selectivity_pct": 2.897585346, - "r_rows": 183, - "r_lookups": 6, - "r_selectivity_pct": 66.66666667, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "loops": 3.05, "r_loops": 1, "rows": 4, - "r_rows": 4, + "r_rows": 6, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 2.897585392, - "r_filtered": 100, + "r_filtered": 66.66666667, "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'" } } diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index 78fc80e6ad7..8210d0834cb 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -60,22 +60,22 @@ set optimizer_use_condition_selectivity=2; select 100 * (select count(*) from lineitem -WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 45 +WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 ) / (select count(*) from lineitem where l_shipdate BETWEEN '1997-01-01' AND '1997-06-30') as correct_r_filtered_when_using_l_shipdate; correct_r_filtered_when_using_l_shipdate -11.7647 +6.6667 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -87,23 +87,23 @@ EXPLAIN "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 605, - "selectivity_pct": 10.07493755 + "rows": 510, + "selectivity_pct": 8.492922565 }, "loops": 1, - "rows": 510, + "rows": 349, "cost": "COST_REPLACED", - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.492922783, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -111,12 +111,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) 60.00 (11%) 10.07 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) 34.00 (9%) 8.49 100.00 Using index condition; Using where; Using rowid filter set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -133,33 +133,33 @@ ANALYZE "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 605, - "selectivity_pct": 10.07493755, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "rows": 510, + "selectivity_pct": 8.492922565, + "r_rows": 510, + "r_lookups": 349, + "r_selectivity_pct": 9.742120344, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, - "rows": 510, - "r_rows": 60, + "rows": 349, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, + "filtered": 8.492922783, "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -167,21 +167,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=on' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -194,49 +186,31 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 510 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_quantity 9 NULL 349 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; EXPLAIN { "query_block": { @@ -248,15 +222,15 @@ EXPLAIN "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, - "rows": 510, + "rows": 349, "cost": "COST_REPLACED", - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.492922783, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -264,12 +238,12 @@ EXPLAIN } set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 510 510.00 10.07 11.76 Using index condition; Using where +1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_quantity 9 NULL 349 349.00 8.49 9.74 Using index condition; Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; ANALYZE { "query_optimization": { @@ -286,20 +260,20 @@ ANALYZE "table_name": "lineitem", "access_type": "range", "possible_keys": ["i_l_shipdate", "i_l_quantity"], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "loops": 1, "r_loops": 1, - "rows": 510, - "r_rows": 510, + "rows": 349, + "r_rows": 349, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, - "r_filtered": 11.76470588, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.492922783, + "r_filtered": 9.742120344, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } } ] @@ -307,21 +281,13 @@ ANALYZE } set statement optimizer_switch='rowid_filter=off' for SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45; +l_quantity > 47; l_orderkey l_linenumber l_shipdate l_quantity -1121 5 1997-04-27 47 1121 6 1997-04-21 50 1441 7 1997-06-07 50 -1443 1 1997-02-05 47 1473 1 1997-05-05 50 -1568 2 1997-04-06 46 -1632 1 1997-01-25 47 -1632 3 1997-01-29 47 1954 7 1997-06-04 49 -1959 1 1997-05-05 46 2151 3 1997-01-20 49 -2177 5 1997-05-10 46 -2369 2 1997-01-02 47 2469 3 1997-01-11 48 2469 6 1997-03-03 49 2470 2 1997-06-02 50 @@ -334,41 +300,23 @@ l_orderkey l_linenumber l_shipdate l_quantity 3429 1 1997-04-08 48 3490 2 1997-06-27 50 3619 1 1997-01-22 49 -3619 3 1997-01-31 46 -3969 3 1997-05-29 46 4005 4 1997-01-31 49 -4036 1 1997-06-21 46 4066 4 1997-02-17 49 -4098 1 1997-01-26 46 -422 3 1997-06-21 46 -4258 3 1997-01-02 46 -4421 2 1997-04-21 46 -4421 3 1997-05-25 46 4453 3 1997-05-29 48 4484 7 1997-03-17 50 -4609 3 1997-02-11 46 484 1 1997-03-06 49 484 3 1997-01-24 50 484 5 1997-03-05 48 485 1 1997-03-28 50 -4868 1 1997-04-29 47 4868 3 1997-04-23 49 4934 1 1997-05-20 48 4967 1 1997-05-27 50 -5090 2 1997-04-05 46 5152 2 1997-03-10 50 5158 4 1997-04-10 49 -5606 3 1997-03-11 46 -5606 7 1997-02-01 46 -5762 4 1997-03-02 47 581 3 1997-02-27 49 5829 5 1997-01-31 49 -5831 4 1997-02-24 46 -5895 2 1997-04-27 47 5895 3 1997-03-15 49 5952 1 1997-06-30 49 -705 1 1997-04-18 46 -836 3 1997-03-21 46 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND @@ -662,15 +610,15 @@ o_orderkey l_linenumber l_shipdate o_totalprice set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) Using index condition; Using where; Using rowid filter 1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -689,23 +637,23 @@ EXPLAIN "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 605, - "selectivity_pct": 10.07493755 + "rows": 510, + "selectivity_pct": 8.492922565 }, "loops": 1, - "rows": 510, + "rows": 349, "cost": "COST_REPLACED", - "filtered": 10.07493782, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "filtered": 8.492922783, + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -717,7 +665,7 @@ EXPLAIN "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 51.38218152, + "loops": 29.64029975, "rows": 1, "cost": "COST_REPLACED", "filtered": 9.600000381, @@ -730,15 +678,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) 60.00 (11%) 10.07 100.00 Using index condition; Using where; Using rowid filter -1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.60 26.67 Using where +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) 34.00 (9%) 8.49 100.00 Using index condition; Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.60 26.47 Using where set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -762,33 +710,33 @@ ANALYZE "i_l_orderkey_quantity", "i_l_quantity" ], - "key": "i_l_shipdate", - "key_length": "4", - "used_key_parts": ["l_shipDATE"], + "key": "i_l_quantity", + "key_length": "9", + "used_key_parts": ["l_quantity"], "rowid_filter": { "range": { - "key": "i_l_quantity", - "used_key_parts": ["l_quantity"] + "key": "i_l_shipdate", + "used_key_parts": ["l_shipDATE"] }, - "rows": 605, - "selectivity_pct": 10.07493755, - "r_rows": 605, - "r_lookups": 510, - "r_selectivity_pct": 11.76470588, + "rows": 510, + "selectivity_pct": 8.492922565, + "r_rows": 510, + "r_lookups": 349, + "r_selectivity_pct": 9.742120344, "r_buffer_size": "REPLACED", "r_filling_time_ms": "REPLACED" }, "loops": 1, "r_loops": 1, - "rows": 510, - "r_rows": 60, + "rows": 349, + "r_rows": 34, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 10.07493782, + "filtered": 8.492922783, "r_filtered": 100, - "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'", - "attached_condition": "lineitem.l_quantity > 45" + "index_condition": "lineitem.l_quantity > 47", + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'" } }, { @@ -800,15 +748,15 @@ ANALYZE "key_length": "4", "used_key_parts": ["o_orderkey"], "ref": ["dbt3_s001.lineitem.l_orderkey"], - "loops": 51.38218152, - "r_loops": 60, + "loops": 29.64029975, + "r_loops": 34, "rows": 1, "r_rows": 1, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 9.600000381, - "r_filtered": 26.66666667, + "r_filtered": 26.47058824, "attached_condition": "orders.o_totalprice between 180000 and 230000" } } @@ -818,29 +766,22 @@ ANALYZE set statement optimizer_switch='rowid_filter=on' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 Using where; Using index @@ -848,7 +789,7 @@ id select_type table type possible_keys key key_len ref rows Extra set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; EXPLAIN { @@ -890,8 +831,8 @@ EXPLAIN "loops": 144, "rows": 4, "cost": "COST_REPLACED", - "filtered": 0.855656624, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "filtered": 0.493593663, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 47" } } ] @@ -900,15 +841,15 @@ EXPLAIN set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 144 144.00 100.00 100.00 Using where; Using index -1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.62 0.86 1.68 Using where +1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.62 0.49 0.94 Using where set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; ANALYZE { @@ -964,9 +905,9 @@ ANALYZE "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", - "filtered": 0.855656624, - "r_filtered": 1.677148847, - "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45" + "filtered": 0.493593663, + "r_filtered": 0.943396226, + "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 47" } } ] @@ -975,32 +916,25 @@ ANALYZE set statement optimizer_switch='rowid_filter=off' for SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; o_orderkey l_linenumber l_shipdate l_quantity o_totalprice -1632 1 1997-01-25 47 183286.33 -1632 3 1997-01-29 47 183286.33 -2177 5 1997-05-10 46 183493.42 2469 3 1997-01-11 48 192074.23 2469 6 1997-03-03 49 192074.23 3619 1 1997-01-22 49 222274.54 -3619 3 1997-01-31 46 222274.54 484 1 1997-03-06 49 219920.62 484 3 1997-01-24 50 219920.62 484 5 1997-03-05 48 219920.62 4934 1 1997-05-20 48 180478.16 -5606 3 1997-03-11 46 219959.08 -5606 7 1997-02-01 46 219959.08 5829 5 1997-01-31 49 183734.56 -5895 2 1997-04-27 47 201419.83 5895 3 1997-03-15 49 201419.83 set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT STRAIGHT_JOIN o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice FROM lineitem JOIN orders ON o_orderkey=l_orderkey WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND -l_quantity > 45 AND +l_quantity > 47 AND o_totalprice between 180000 and 230000; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 510 (10%) Using index condition; Using where; Using rowid filter +1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) Using index condition; Using where; Using rowid filter 1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice FROM orders JOIN lineitem ON o_orderkey=l_orderkey @@ -2297,6 +2231,7 @@ insert into t1 values (81,'a','a',20),(82,'a','a',0),(83,'a','a',0),(84,'a','a',null), (85,'a','a',-1),(86,'a','a',5),(87,'a','a',null),(88,'a','a',160), (89,null,null,null),(90,'a','a',14785),(91,'a','a',0),(92,'a','a',null); +insert into t1 values (100,null,null,null); analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected @@ -2313,8 +2248,8 @@ union ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter -2 UNION t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter +1 PRIMARY t1 ref|filter f1,f2 f1|f1 13|13 const 2 (3%) Using index condition; Using where; Using rowid filter +2 UNION t1 ref|filter f1,f2 f1|f1 13|13 const 2 (3%) Using index condition; Using where; Using rowid filter NULL UNION RESULT ALL NULL NULL NULL NULL NULL explain format=json ( select * from t1 where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a'))) @@ -2347,13 +2282,13 @@ EXPLAIN "key": "f1", "used_key_parts": ["f1"] }, - "rows": 1, - "selectivity_pct": 1.587301587 + "rows": 2, + "selectivity_pct": 3.125 }, "loops": 1, - "rows": 1, + "rows": 2, "cost": "COST_REPLACED", - "filtered": 1.587301612, + "filtered": 3.125, "index_condition": "t1.f1 is null", "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } @@ -2381,13 +2316,13 @@ EXPLAIN "key": "f1", "used_key_parts": ["f1"] }, - "rows": 1, - "selectivity_pct": 1.587301587 + "rows": 2, + "selectivity_pct": 3.125 }, "loops": 1, - "rows": 1, + "rows": 2, "cost": "COST_REPLACED", - "filtered": 1.587301612, + "filtered": 3.125, "index_condition": "t1.f1 is null", "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')" } @@ -2416,7 +2351,7 @@ id y x explain extended select * from t1 join t2 on t1.id = t2.x where t2.y = 2 and t1.id = 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const # # -1 SIMPLE t2 ref|filter x,y y|x 5|5 const # # Using where; Using rowid filter +1 SIMPLE t2 index_merge x,y y,x 5,5 NULL # # Using intersect(y,x); Using where; Using index Warnings: Note 1003 select 1 AS `id`,`test`.`t2`.`y` AS `y`,`test`.`t2`.`x` AS `x` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`y` = 2 and `test`.`t2`.`x` = 1 drop table t1, t2; diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index c81cfc71d28..77f2e7c1b59 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -37,6 +37,7 @@ insert into t1 values (81,'a','a',20),(82,'a','a',0),(83,'a','a',0),(84,'a','a',null), (85,'a','a',-1),(86,'a','a',5),(87,'a','a',null),(88,'a','a',160), (89,null,null,null),(90,'a','a',14785),(91,'a','a',0),(92,'a','a',null); +insert into t1 values (100,null,null,null); analyze table t1; diff --git a/mysql-test/main/rowid_filter_innodb_debug.result b/mysql-test/main/rowid_filter_innodb_debug.result index af800346f75..7e5446c9025 100644 --- a/mysql-test/main/rowid_filter_innodb_debug.result +++ b/mysql-test/main/rowid_filter_innodb_debug.result @@ -2,8 +2,6 @@ set default_storage_engine=innodb; # # MDEV-22761 KILL QUERY during rowid_filter, crashes # -create table t1(a int); -insert into t1 select seq from seq_1_to_1000; create table t2(a int); insert into t2 select seq from seq_1_to_100; CREATE TABLE t3 ( @@ -25,16 +23,16 @@ test.t2 analyze status OK test.t3 analyze status Engine-independent statistics collected test.t3 analyze status OK explain -select * from t2, t3 +select straight_join * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); +t3.key1=t2.a and t3.key2 between 2 and 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where 1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 1 (0%) Using where; Using rowid filter set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; -select * from t2, t3 +select straight_join * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); +t3.key1=t2.a and t3.key2 between 2 and 10; connect con1, localhost, root,,; set debug_sync='now WAIT_FOR at_rowid_filter_check'; kill query $target_id; @@ -43,5 +41,5 @@ connection default; disconnect con1; ERROR 70100: Query execution was interrupted set debug_sync='RESET'; -drop table t1,t2,t3; +drop table t2,t3; set default_storage_engine=default; diff --git a/mysql-test/main/rowid_filter_myisam.result b/mysql-test/main/rowid_filter_myisam.result index 0a56f87f25f..7f05b6167fd 100644 --- a/mysql-test/main/rowid_filter_myisam.result +++ b/mysql-test/main/rowid_filter_myisam.result @@ -126,7 +126,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where -1 PRIMARY t1 eq_ref|filter PRIMARY,b1 PRIMARY|b1 4|4 test.t2.a2 1 (87%) 87.00 Using where; Using rowid filter +1 PRIMARY t1 eq_ref PRIMARY,b1 PRIMARY 4 test.t2.a2 1 87.00 Using where 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`pk1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t2`.`a2` <> `test`.`t2`.`pk2` @@ -158,14 +158,6 @@ EXPLAIN "key_length": "4", "used_key_parts": ["pk1"], "ref": ["test.t2.a2"], - "rowid_filter": { - "range": { - "key": "b1", - "used_key_parts": ["b1"] - }, - "rows": 87, - "selectivity_pct": 87 - }, "loops": 101, "rows": 1, "cost": "COST_REPLACED", @@ -613,28 +605,15 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 863, - "selectivity_pct": 8.63, - "r_rows": 1000, - "r_lookups": 44, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "loops": 1, "r_loops": 1, "rows": 44, - "r_rows": 0, + "r_rows": 44, "cost": "REPLACED", "r_table_time_ms": "REPLACED", "r_other_time_ms": "REPLACED", "filtered": 8.630000114, - "r_filtered": 100, + "r_filtered": 0, "index_condition": "t1.nm like '3400%' or t1.nm like '3402%' or t1.nm like '3403%' or t1.nm like '3404%' or t1.nm like '3405%' or t1.nm like '3406%' or t1.nm like '3407%' or t1.nm like '3409%' or t1.nm like '3411%' or t1.nm like '3412%' or t1.nm like '3413%' or t1.nm like '3414%' or t1.nm like '3415%' or t1.nm like '3416%' or t1.nm like '3417%' or t1.nm like '3418%' or t1.nm like '3419%' or t1.nm like '3421%' or t1.nm like '3422%' or t1.nm like '3423%' or t1.nm like '3424%' or t1.nm like '3425%' or t1.nm like '3426%' or t1.nm like '3427%' or t1.nm like '3428%' or t1.nm like '3429%' or t1.nm like '3430%' or t1.nm like '3431%' or t1.nm like '3432%' or t1.nm like '3433%' or t1.nm like '3434%' or t1.nm like '3435%' or t1.nm like '3436%' or t1.nm like '3437%' or t1.nm like '3439%' or t1.nm like '3440%' or t1.nm like '3441%' or t1.nm like '3442%' or t1.nm like '3443%' or t1.nm like '3444%' or t1.nm like '3445%' or t1.nm like '3446%' or t1.nm like '3447%' or t1.nm like '3448%'", "attached_condition": "t1.fl2 = 0" } @@ -682,19 +661,6 @@ ANALYZE "key": "idx1", "key_length": "256", "used_key_parts": ["nm"], - "rowid_filter": { - "range": { - "key": "idx2", - "used_key_parts": ["fl2"] - }, - "rows": 853, - "selectivity_pct": 8.53, - "r_rows": 987, - "r_lookups": 0, - "r_selectivity_pct": 0, - "r_buffer_size": "REPLACED", - "r_filling_time_ms": "REPLACED" - }, "loops": 1, "r_loops": 1, "rows": 44, diff --git a/mysql-test/main/rowid_filter_myisam_debug.result b/mysql-test/main/rowid_filter_myisam_debug.result index d68714cc303..263a8e9970d 100644 --- a/mysql-test/main/rowid_filter_myisam_debug.result +++ b/mysql-test/main/rowid_filter_myisam_debug.result @@ -1,8 +1,6 @@ # # MDEV-22761 KILL QUERY during rowid_filter, crashes # -create table t1(a int); -insert into t1 select seq from seq_1_to_1000; create table t2(a int); insert into t2 select seq from seq_1_to_100; CREATE TABLE t3 ( @@ -24,16 +22,16 @@ test.t2 analyze status OK test.t3 analyze status Engine-independent statistics collected test.t3 analyze status Table is already up to date explain -select * from t2, t3 +select straight_join * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); +t3.key1=t2.a and t3.key2 between 2 and 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where 1 SIMPLE t3 ref|filter key1,key2 key1|key2 5|5 test.t2.a 1 (0%) Using where; Using rowid filter set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; -select * from t2, t3 +select straight_join * from t2, t3 where -t3.key1=t2.a and t3.key2 in (2,3,4,5,6,7,8,9,10); +t3.key1=t2.a and t3.key2 between 2 and 10; connect con1, localhost, root,,; set debug_sync='now WAIT_FOR at_rowid_filter_check'; kill query $target_id; @@ -42,4 +40,4 @@ connection default; disconnect con1; ERROR 70100: Query execution was interrupted set debug_sync='RESET'; -drop table t1,t2,t3; +drop table t2,t3; diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index bdeeb494a14..4f7afe933ff 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where 1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( @@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3690,7 +3690,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3767,11 +3767,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3781,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 791e7983508..177edbc4acf 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -3532,7 +3532,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Rowid-ordered scan; Using rowid filter +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE t2 ref c c 5 test.t1.a 2 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan DROP TABLE t1, t2; create table t1 ( @@ -3693,7 +3693,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3701,7 +3701,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3778,11 +3778,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3792,7 +3792,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result index bdeeb494a14..4f7afe933ff 100644 --- a/mysql-test/main/select_pkeycache.result +++ b/mysql-test/main/select_pkeycache.result @@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,b b|PRIMARY 5|4 NULL 3 (90%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 range PRIMARY,b b 5 NULL 3 Using index condition; Using where 1 SIMPLE t2 ref c c 5 test.t1.a 2 DROP TABLE t1, t2; create table t1 ( @@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where EXPLAIN SELECT t3.a FROM t1,t2,t3 WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND @@ -3690,7 +3690,7 @@ t3.c IN ('bb','ee'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where -1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter +1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where DROP TABLE t1,t2,t3; CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); CREATE TABLE t2 ( f11 int PRIMARY KEY ); @@ -3767,11 +3767,11 @@ COUNT(*) EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter +1 SIMPLE t1 index_merge idx1,idx2 idx2,idx1 4,10 NULL 1 Using intersect(idx2,idx1); Using where; Using index EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|5 const 2 (27%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; id select_type table type possible_keys key key_len ref rows Extra @@ -3781,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null); EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter +1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where EXPLAIN SELECT * FROM t1 WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 6bd8fdf8d2b..54c39d090d2 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -1892,7 +1892,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter +2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1904,7 +1904,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 -2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter +2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 965a1ffd117..055ae1f20c4 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1899,7 +1899,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter +2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 @@ -1911,7 +1911,7 @@ WHERE A.a=t1.a AND t2.b < 20); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index -2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter +2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where set optimizer_switch= @save_optimizer_switch; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; drop table t1,t2; diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index d9ee8cf14c4..414497d5ad1 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -217,7 +217,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition 1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where 1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 -1 SIMPLE orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (27%) Using where; Using rowid filter +1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where 1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where 1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where select o_year, diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test index 8b9f8361d55..895db3ce72e 100644 --- a/mysql-test/main/stat_tables.test +++ b/mysql-test/main/stat_tables.test @@ -126,7 +126,6 @@ order by o_year; eval EXPLAIN $Q8; eval $Q8; - let $Q9= select nation, o_year, sum(amount) as sum_profit from (select n_name as nation, diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 0a8a680adc0..fa10a4aa066 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -341,7 +341,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using rowid filter +1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index c3e3a77c679..f09e70e90ee 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -348,7 +348,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter +1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index a04e6333b07..cf2b1c4840f 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -343,7 +343,7 @@ WHERE Language='English' AND Percentage > 10 AND t2.Population > 100000); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary -1 PRIMARY t2 eq_ref|filter PRIMARY,Population PRIMARY|Population 3|4 test.t1.Country 1 (75%) Using where; End temporary; Using rowid filter +1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where set optimizer_switch=@bug35674_save_optimizer_switch; DROP TABLE t1,t2,t3; diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result index d990d8b0855..a421ba6d3ea 100644 --- a/mysql-test/suite/maria/icp.result +++ b/mysql-test/suite/maria/icp.result @@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ORDER BY c1 LIMIT 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range|filter PRIMARY,k1 k1|PRIMARY 5|4 NULL 4 (38%) Using index condition; Using where; Using rowid filter +1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using index condition; Using where DROP TABLE t1; # # diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 611917ab1a6..02b5770aa8c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5130,13 +5130,13 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num) cost of sweep */ -static double get_sweep_read_cost(const PARAM *param, ha_rows records, +static double get_sweep_read_cost(const PARAM *param, double records, bool add_time_for_compare) { DBUG_ENTER("get_sweep_read_cost"); #ifndef OLD_SWEEP_COST handler *file= param->table->file; - IO_AND_CPU_COST engine_cost= file->ha_rnd_pos_call_time(records); + IO_AND_CPU_COST engine_cost= file->ha_rnd_pos_call_time(double2rows(ceil(records))); double cost; if (add_time_for_compare) { @@ -5420,7 +5420,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, /* Calculate cost(rowid_to_row_scan) */ { /* imerge_cost already includes WHERE_COST */ - double sweep_cost= get_sweep_read_cost(param, non_cpk_scan_records, 0); + double sweep_cost= get_sweep_read_cost(param, rows2double(non_cpk_scan_records), 0); imerge_cost+= sweep_cost; trace_best_disjunct. add("rows", non_cpk_scan_records). @@ -5572,7 +5572,7 @@ skip_to_ror_scan: roru_total_cost= (roru_index_costs + rows2double(roru_total_records)*log((double)n_child_scans) * ROWID_COMPARE_COST_THD(param->thd) / M_LN2 + - get_sweep_read_cost(param, roru_total_records, 0)); + get_sweep_read_cost(param, rows2double(roru_total_records), 0)); DBUG_PRINT("info", ("ROR-union: cost %g, %zu members", roru_total_cost, n_child_scans)); @@ -6523,7 +6523,7 @@ bool check_index_intersect_extension(THD *thd, The cost after sweeep can be bigger than cutoff, but that is ok as the end cost can decrease when we add the next index. */ - cost+= get_sweep_read_cost(common_info->param, records, 1); + cost+= get_sweep_read_cost(common_info->param, rows2double(records), 1); next->cost= cost; next->length= curr->length+1; @@ -7197,8 +7197,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info, DBUG_PRINT("info", ("info->total_cost: %g", info->total_cost)); if (!info->is_covering) { - double sweep_cost= get_sweep_read_cost(info->param, - double2rows(info->out_rows), 1); + double sweep_cost= get_sweep_read_cost(info->param, info->out_rows, 1); info->total_cost+= sweep_cost; trace_costs->add("disk_sweep_cost", sweep_cost); DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost)); diff --git a/sql/optimizer_defaults.h b/sql/optimizer_defaults.h index a3c22d898cf..4eaa30757ce 100644 --- a/sql/optimizer_defaults.h +++ b/sql/optimizer_defaults.h @@ -91,7 +91,7 @@ using and calling Rowid_filter_sorted_array::check() from the engine */ #define ROWID_FILTER_PER_CHECK_MODIFIER 4 /* times key_copy_cost */ -#define ROWID_FILTER_PER_ELEMENT_MODIFIER 3 /* times rowid_compare_cost */ +#define ROWID_FILTER_PER_ELEMENT_MODIFIER 1 /* times rowid_compare_cost */ /* Average disk seek time on a hard disk is 8-10 ms, which is also diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc index f034c045938..2c257b11e47 100644 --- a/sql/rowid_filter.cc +++ b/sql/rowid_filter.cc @@ -33,7 +33,7 @@ lookup_cost(Rowid_filter_container_type cont_type) { switch (cont_type) { case SORTED_ARRAY_CONTAINER: - return log(est_elements) * rowid_compare_cost + base_lookup_cost; + return log2(est_elements) * rowid_compare_cost + base_lookup_cost; default: DBUG_ASSERT(0); return 0; @@ -161,9 +161,9 @@ Range_rowid_filter_cost_info::build_cost(Rowid_filter_container_type cont_type) switch (cont_type) { case SORTED_ARRAY_CONTAINER: /* Add cost of filling container and cost of sorting */ - cost= (est_elements * - (costs->rowid_copy_cost + // Copying rowid - costs->rowid_cmp_cost * log2(est_elements))); // Sort + cost+= (est_elements * + (costs->rowid_copy_cost + // Copying rowid + costs->rowid_cmp_cost * log2(est_elements))); // Sort break; default: DBUG_ASSERT(0);