Commit 3c1b7fb0 authored by Monty's avatar Monty Committed by Sergei Petrunia

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.
parent 9c401c8c
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
--echo # MDEV-22761 KILL QUERY during rowid_filter, crashes --echo # MDEV-22761 KILL QUERY during rowid_filter, crashes
--echo # --echo #
create table t1(a int);
insert into t1 select seq from seq_1_to_1000;
create table t2(a int); create table t2(a int);
insert into t2 select seq from seq_1_to_100; insert into t2 select seq from seq_1_to_100;
...@@ -30,17 +27,17 @@ where table_schema=database() and table_name='t3'; ...@@ -30,17 +27,17 @@ where table_schema=database() and table_name='t3';
analyze table t2,t3; analyze table t2,t3;
explain explain
select * from t2, t3 select straight_join * from t2, t3
where 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()`; let $target_id= `select connection_id()`;
set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go'; set debug_sync='handler_rowid_filter_check SIGNAL at_rowid_filter_check WAIT_FOR go';
send send
select * from t2, t3 select straight_join * from t2, t3
where 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,,); connect (con1, localhost, root,,);
set debug_sync='now WAIT_FOR at_rowid_filter_check'; set debug_sync='now WAIT_FOR at_rowid_filter_check';
...@@ -54,5 +51,5 @@ disconnect con1; ...@@ -54,5 +51,5 @@ disconnect con1;
reap; reap;
set debug_sync='RESET'; set debug_sync='RESET';
drop table t1,t2,t3; drop table t2,t3;
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
...@@ -1558,7 +1558,7 @@ This should be intersect: ...@@ -1558,7 +1558,7 @@ This should be intersect:
set optimizer_switch=default; set optimizer_switch=default;
explain select * from t1 where a=10 and b=10; explain select * from t1 where a=10 and b=10;
id select_type table type possible_keys key key_len ref rows Extra 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: No intersect when index_merge is disabled:
set optimizer_switch='default,index_merge=off,rowid_filter=off'; set optimizer_switch='default,index_merge=off,rowid_filter=off';
explain select * from t1 where a=10 and b=10; explain select * from t1 where a=10 and b=10;
......
...@@ -2086,7 +2086,7 @@ ON t6.b >= 2 AND t5.b=t7.b AND ...@@ -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 id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 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 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 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 SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5 FROM t5
......
...@@ -2380,12 +2380,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { ...@@ -2380,12 +2380,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"rowid_filters": [ "rowid_filters": [
{ {
"key": "a_b", "key": "a_b",
"build_cost": 6.9153e-4, "build_cost": 0.005839142,
"rows": 41 "rows": 41
}, },
{ {
"key": "a_c", "key": "a_c",
"build_cost": 0.0040552, "build_cost": 0.024214742,
"rows": 180 "rows": 180
} }
] ]
...@@ -3832,17 +3832,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { ...@@ -3832,17 +3832,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"rowid_filters": [ "rowid_filters": [
{ {
"key": "pk", "key": "pk",
"build_cost": 0.000002653, "build_cost": 0.000899465,
"rows": 1 "rows": 1
}, },
{ {
"key": "pk_a", "key": "pk_a",
"build_cost": 0.000002653, "build_cost": 0.000899465,
"rows": 1 "rows": 1
}, },
{ {
"key": "pk_a_b", "key": "pk_a_b",
"build_cost": 0.000002653, "build_cost": 0.000899465,
"rows": 1 "rows": 1
} }
] ]
...@@ -12277,12 +12277,12 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12277,12 +12277,12 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"rowid_filters": [ "rowid_filters": [
{ {
"key": "a", "key": "a",
"build_cost": 9.95653e-5, "build_cost": 0.001846537,
"rows": 9 "rows": 9
}, },
{ {
"key": "b", "key": "b",
"build_cost": 3.004222e-4, "build_cost": 0.003322634,
"rows": 21 "rows": 21
} }
] ]
...@@ -12325,17 +12325,17 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12325,17 +12325,17 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"filter": { "filter": {
"rowid_filter_index": "b", "rowid_filter_index": "b",
"index_only_cost": 0.001605807, "index_only_cost": 0.001605807,
"filter_startup_cost": 3.004222e-4, "filter_startup_cost": 0.003322634,
"find_key_and_filter_lookup_cost": 7.827422e-4, "find_key_and_filter_lookup_cost": 6.695354e-4,
"filter_selectivity": 0.021, "filter_selectivity": 0.021,
"original_rows": 9, "original_rows": 9,
"new_rows": 0.189, "new_rows": 0.189,
"original_access_cost": 0.011607363, "original_access_cost": 0.011607363,
"with_filter_access_cost": 0.002598582, "with_filter_access_cost": 0.002485375,
"original_found_rows_cost": 0.010001556, "original_found_rows_cost": 0.010001556,
"with_filter_found_rows_cost": 2.100327e-4, "with_filter_found_rows_cost": 2.100327e-4,
"org_cost": 0.011895363, "org_cost": 0.011895363,
"filter_cost": 0.002905052, "filter_cost": 0.005814057,
"filter_used": true "filter_used": true
}, },
"access_type": "range", "access_type": "range",
...@@ -12343,7 +12343,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12343,7 +12343,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"rows": 9, "rows": 9,
"rows_after_filter": 0.189, "rows_after_filter": 0.189,
"rows_out": 0.017766, "rows_out": 0.017766,
"cost": 0.002905052, "cost": 0.005814057,
"chosen": true "chosen": true
} }
], ],
...@@ -12351,7 +12351,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12351,7 +12351,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"type": "range", "type": "range",
"rows_read": 0.189, "rows_read": 0.189,
"rows_out": 0.017766, "rows_out": 0.017766,
"cost": 0.002905052, "cost": 0.005814057,
"uses_join_buffering": false, "uses_join_buffering": false,
"rowid_filter_index": "b" "rowid_filter_index": "b"
} }
...@@ -12363,7 +12363,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12363,7 +12363,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"plan_prefix": "", "plan_prefix": "",
"table": "t1", "table": "t1",
"rows_for_plan": 0.017766, "rows_for_plan": 0.017766,
"cost_for_plan": 0.002905052, "cost_for_plan": 0.005814057,
"pushdown_cond_selectivity": 0.094, "pushdown_cond_selectivity": 0.094,
"filtered": 0.1974, "filtered": 0.1974,
"rows_out": 0.017766 "rows_out": 0.017766
...@@ -12373,7 +12373,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 { ...@@ -12373,7 +12373,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
{ {
"best_join_order": ["t1"], "best_join_order": ["t1"],
"rows": 0.017766, "rows": 0.017766,
"cost": 0.002905052 "cost": 0.005814057
}, },
{ {
"table": "t1", "table": "t1",
...@@ -12470,7 +12470,7 @@ EXPLAIN ...@@ -12470,7 +12470,7 @@ EXPLAIN
{ {
"query_block": { "query_block": {
"select_id": 1, "select_id": 1,
"cost": 2.303362315, "cost": 2.662022424,
"nested_loop": [ "nested_loop": [
{ {
"table": { "table": {
...@@ -12502,7 +12502,7 @@ EXPLAIN ...@@ -12502,7 +12502,7 @@ EXPLAIN
}, },
"loops": 3, "loops": 3,
"rows": 1000, "rows": 1000,
"cost": 2.2928575, "cost": 2.651517609,
"filtered": 43.11999893, "filtered": 43.11999893,
"attached_condition": "t1.b < 5000 and t1.c < 1000" "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 ...@@ -12673,7 +12673,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"rowid_filters": [ "rowid_filters": [
{ {
"key": "b", "key": "b",
"build_cost": 0.149564727, "build_cost": 0.611957109,
"rows": 4312 "rows": 4312
} }
] ]
...@@ -12779,21 +12779,21 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and ...@@ -12779,21 +12779,21 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"filter": { "filter": {
"rowid_filter_index": "b", "rowid_filter_index": "b",
"index_only_cost": 0.092096742, "index_only_cost": 0.092096742,
"filter_startup_cost": 0.149564727, "filter_startup_cost": 0.611957109,
"find_key_and_filter_lookup_cost": 0.129350121, "find_key_and_filter_lookup_cost": 0.094772697,
"filter_selectivity": 0.4312, "filter_selectivity": 0.4312,
"original_rows": 1000, "original_rows": 1000,
"new_rows": 431.2, "new_rows": 431.2,
"original_access_cost": 1.203380742, "original_access_cost": 1.203380742,
"with_filter_access_cost": 0.700632524, "with_filter_access_cost": 0.6660551,
"original_found_rows_cost": 1.111284, "original_found_rows_cost": 1.111284,
"with_filter_found_rows_cost": 0.479185661, "with_filter_found_rows_cost": 0.479185661,
"org_cost": 3.706142226, "org_cost": 3.706142226,
"filter_cost": 2.2928575, "filter_cost": 2.651517609,
"filter_used": true "filter_used": true
}, },
"rows": 431.2, "rows": 431.2,
"cost": 2.2928575, "cost": 2.651517609,
"chosen": true "chosen": true
}, },
{ {
......
...@@ -394,8 +394,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -394,8 +394,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"index": "key2", "index": "key2",
"index_scan_cost": 0.240986767, "index_scan_cost": 0.240986767,
"cumulated_index_scan_cost": 0.481973534, "cumulated_index_scan_cost": 0.481973534,
"disk_sweep_cost": 0.088032868, "disk_sweep_cost": 0.089164506,
"cumulative_total_cost": 0.570006402, "cumulative_total_cost": 0.57113804,
"usable": true, "usable": true,
"matching_rows_now": 77.6360508, "matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false, "intersect_covering_with_this_index": false,
...@@ -420,7 +420,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -420,7 +420,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index" "cause": "no clustered pk index"
}, },
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"chosen": true "chosen": true
}, },
...@@ -436,7 +436,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ...@@ -436,7 +436,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{ {
"type": "index_roworder_intersect", "type": "index_roworder_intersect",
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"clustered_pk_scan": false, "clustered_pk_scan": false,
"intersect_of": "intersect_of":
...@@ -458,7 +458,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ...@@ -458,7 +458,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
] ]
}, },
"rows_for_plan": 77, "rows_for_plan": 77,
"cost_for_plan": 0.572490756, "cost_for_plan": 0.573622393,
"chosen": true "chosen": true
} }
] ]
...@@ -572,8 +572,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -572,8 +572,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"index": "key2", "index": "key2",
"index_scan_cost": 0.240986767, "index_scan_cost": 0.240986767,
"cumulated_index_scan_cost": 0.481973534, "cumulated_index_scan_cost": 0.481973534,
"disk_sweep_cost": 0.088032868, "disk_sweep_cost": 0.089164506,
"cumulative_total_cost": 0.570006402, "cumulative_total_cost": 0.57113804,
"usable": true, "usable": true,
"matching_rows_now": 77.6360508, "matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false, "intersect_covering_with_this_index": false,
...@@ -586,7 +586,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -586,7 +586,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index" "cause": "no clustered pk index"
}, },
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"chosen": true "chosen": true
} }
...@@ -616,8 +616,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -616,8 +616,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"index": "key4", "index": "key4",
"index_scan_cost": 0.240986767, "index_scan_cost": 0.240986767,
"cumulated_index_scan_cost": 0.481973534, "cumulated_index_scan_cost": 0.481973534,
"disk_sweep_cost": 0.088032868, "disk_sweep_cost": 0.089164506,
"cumulative_total_cost": 0.570006402, "cumulative_total_cost": 0.57113804,
"usable": true, "usable": true,
"matching_rows_now": 77.6360508, "matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false, "intersect_covering_with_this_index": false,
...@@ -630,7 +630,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) ...@@ -630,7 +630,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index" "cause": "no clustered pk index"
}, },
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"chosen": true "chosen": true
} }
...@@ -655,7 +655,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ...@@ -655,7 +655,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{ {
"type": "index_roworder_intersect", "type": "index_roworder_intersect",
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"clustered_pk_scan": false, "clustered_pk_scan": false,
"intersect_of": "intersect_of":
...@@ -679,7 +679,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary')) ...@@ -679,7 +679,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{ {
"type": "index_roworder_intersect", "type": "index_roworder_intersect",
"rows": 77, "rows": 77,
"cost": 0.572490756, "cost": 0.573622393,
"covering": false, "covering": false,
"clustered_pk_scan": false, "clustered_pk_scan": false,
"intersect_of": "intersect_of":
......
...@@ -178,7 +178,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { ...@@ -178,7 +178,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"rowid_filters": [ "rowid_filters": [
{ {
"key": "key1", "key": "key1",
"build_cost": 0.000002653, "build_cost": 0.001763258,
"rows": 1 "rows": 1
} }
] ]
......
...@@ -1937,7 +1937,7 @@ MOD(seq, 100), ...@@ -1937,7 +1937,7 @@ MOD(seq, 100),
seq_1_to_5000; seq_1_to_5000;
explain select * from t1 partition (p1) where a=10 and b=10; 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 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; flush tables;
select * from t1 partition (p1)where a=10 and b=10; select * from t1 partition (p1)where a=10 and b=10;
pk a b filler pk a b filler
......
...@@ -2677,7 +2677,7 @@ select * from t1 X, t1 Y ...@@ -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); 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 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 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 explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); 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 id select_type table partitions type possible_keys key key_len ref rows Extra
......
...@@ -281,7 +281,7 @@ INSERT INTO t1 VALUES ...@@ -281,7 +281,7 @@ INSERT INTO t1 VALUES
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5); (33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=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 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; SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
a b a b
DROP TABLE t1; DROP TABLE t1;
...@@ -2563,7 +2563,7 @@ insert into t2 values ...@@ -2563,7 +2563,7 @@ insert into t2 values
explain select * from t1,t2 explain select * from t1,t2
where a = d and (a,e) in ((3,3),(7,7),(2,2)); 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 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 1 SIMPLE t1 ref idx idx 5 test.t2.d 8
explain format=json select * from t1,t2 explain format=json select * from t1,t2
where a = d and (a,e) in ((3,3),(7,7),(2,2)); where a = d and (a,e) in ((3,3),(7,7),(2,2));
...@@ -2581,14 +2581,6 @@ EXPLAIN ...@@ -2581,14 +2581,6 @@ EXPLAIN
"key": "idx1", "key": "idx1",
"key_length": "5", "key_length": "5",
"used_key_parts": ["d"], "used_key_parts": ["d"],
"rowid_filter": {
"range": {
"key": "idx2",
"used_key_parts": ["e"]
},
"rows": 12,
"selectivity_pct": 60
},
"loops": 1, "loops": 1,
"rows": 3, "rows": 3,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
......
...@@ -98,7 +98,7 @@ SET @saved_dbug = @@GLOBAL.debug_dbug; ...@@ -98,7 +98,7 @@ SET @saved_dbug = @@GLOBAL.debug_dbug;
set @@global.debug_dbug="+d,ha_index_init_fail"; set @@global.debug_dbug="+d,ha_index_init_fail";
explain select * from t1 where a=10 and b=10; explain select * from t1 where a=10 and b=10;
id select_type table type possible_keys key key_len ref rows Extra 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; select * from t1 where a=10 and b=10;
ERROR HY000: Table definition has changed, please retry transaction ERROR HY000: Table definition has changed, please retry transaction
DROP TABLE t0,t1; DROP TABLE t0,t1;
......
...@@ -949,7 +949,7 @@ WHERE ((Population > 101000 AND Population < 11000) OR ...@@ -949,7 +949,7 @@ WHERE ((Population > 101000 AND Population < 11000) OR
ID BETWEEN 3500 AND 3800) AND Country='USA' ID BETWEEN 3500 AND 3800) AND Country='USA'
AND (Name LIKE 'P%' OR ID BETWEEN 4000 AND 4300); AND (Name LIKE 'P%' OR ID BETWEEN 4000 AND 4300);
id select_type table type possible_keys key key_len ref rows Extra 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 EXPLAIN
SELECT * FROM City SELECT * FROM City
WHERE ((Population > 101000 AND Population < 11000) OR WHERE ((Population > 101000 AND Population < 11000) OR
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ set statement optimizer_switch='rowid_filter=off' for; ...@@ -42,7 +42,7 @@ set statement optimizer_switch='rowid_filter=off' for;
select select
100 * 100 *
(select count(*) from lineitem (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 (select count(*) from lineitem
...@@ -52,7 +52,7 @@ select ...@@ -52,7 +52,7 @@ select
let $q1= let $q1=
SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45; l_quantity > 47;
eval $with_filter EXPLAIN $q1; eval $with_filter EXPLAIN $q1;
--source include/explain-no-costs.inc --source include/explain-no-costs.inc
...@@ -100,7 +100,7 @@ let $q3= ...@@ -100,7 +100,7 @@ let $q3=
SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND 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_totalprice between 180000 and 230000;
eval $with_filter EXPLAIN $q3; eval $with_filter EXPLAIN $q3;
...@@ -125,7 +125,7 @@ eval $without_filter $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 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 FROM lineitem JOIN orders ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND 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_totalprice between 180000 and 230000;
let $q4= let $q4=
......
This diff is collapsed.
This diff is collapsed.
...@@ -37,6 +37,7 @@ insert into t1 values ...@@ -37,6 +37,7 @@ insert into t1 values
(81,'a','a',20),(82,'a','a',0),(83,'a','a',0),(84,'a','a',null), (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), (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); (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; analyze table t1;
......
...@@ -2,8 +2,6 @@ set default_storage_engine=innodb; ...@@ -2,8 +2,6 @@ set default_storage_engine=innodb;
# #
# MDEV-22761 KILL QUERY during rowid_filter, crashes # 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); create table t2(a int);
insert into t2 select seq from seq_1_to_100; insert into t2 select seq from seq_1_to_100;
CREATE TABLE t3 ( CREATE TABLE t3 (
...@@ -25,16 +23,16 @@ test.t2 analyze status OK ...@@ -25,16 +23,16 @@ test.t2 analyze status OK
test.t3 analyze status Engine-independent statistics collected test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK test.t3 analyze status OK
explain explain
select * from t2, t3 select straight_join * from t2, t3
where 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 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 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 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'; 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 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,,; connect con1, localhost, root,,;
set debug_sync='now WAIT_FOR at_rowid_filter_check'; set debug_sync='now WAIT_FOR at_rowid_filter_check';
kill query $target_id; kill query $target_id;
...@@ -43,5 +41,5 @@ connection default; ...@@ -43,5 +41,5 @@ connection default;
disconnect con1; disconnect con1;
ERROR 70100: Query execution was interrupted ERROR 70100: Query execution was interrupted
set debug_sync='RESET'; set debug_sync='RESET';
drop table t1,t2,t3; drop table t2,t3;
set default_storage_engine=default; set default_storage_engine=default;
...@@ -126,7 +126,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 ) ...@@ -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 ); WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 );
id select_type table type possible_keys key key_len ref rows filtered Extra 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 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 2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition
Warnings: 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` 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 ...@@ -158,14 +158,6 @@ EXPLAIN
"key_length": "4", "key_length": "4",
"used_key_parts": ["pk1"], "used_key_parts": ["pk1"],
"ref": ["test.t2.a2"], "ref": ["test.t2.a2"],
"rowid_filter": {
"range": {
"key": "b1",
"used_key_parts": ["b1"]
},
"rows": 87,
"selectivity_pct": 87
},
"loops": 101, "loops": 101,
"rows": 1, "rows": 1,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
...@@ -613,28 +605,15 @@ ANALYZE ...@@ -613,28 +605,15 @@ ANALYZE
"key": "idx1", "key": "idx1",
"key_length": "256", "key_length": "256",
"used_key_parts": ["nm"], "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, "loops": 1,
"r_loops": 1, "r_loops": 1,
"rows": 44, "rows": 44,
"r_rows": 0, "r_rows": 44,
"cost": "REPLACED", "cost": "REPLACED",
"r_table_time_ms": "REPLACED", "r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED", "r_other_time_ms": "REPLACED",
"filtered": 8.630000114, "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%'", "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" "attached_condition": "t1.fl2 = 0"
} }
...@@ -682,19 +661,6 @@ ANALYZE ...@@ -682,19 +661,6 @@ ANALYZE
"key": "idx1", "key": "idx1",
"key_length": "256", "key_length": "256",
"used_key_parts": ["nm"], "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, "loops": 1,
"r_loops": 1, "r_loops": 1,
"rows": 44, "rows": 44,
......
# #
# MDEV-22761 KILL QUERY during rowid_filter, crashes # 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); create table t2(a int);
insert into t2 select seq from seq_1_to_100; insert into t2 select seq from seq_1_to_100;
CREATE TABLE t3 ( CREATE TABLE t3 (
...@@ -24,16 +22,16 @@ test.t2 analyze status OK ...@@ -24,16 +22,16 @@ test.t2 analyze status OK
test.t3 analyze status Engine-independent statistics collected test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status Table is already up to date test.t3 analyze status Table is already up to date
explain explain
select * from t2, t3 select straight_join * from t2, t3
where 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 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 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 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'; 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 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,,; connect con1, localhost, root,,;
set debug_sync='now WAIT_FOR at_rowid_filter_check'; set debug_sync='now WAIT_FOR at_rowid_filter_check';
kill query $target_id; kill query $target_id;
...@@ -42,4 +40,4 @@ connection default; ...@@ -42,4 +40,4 @@ connection default;
disconnect con1; disconnect con1;
ERROR 70100: Query execution was interrupted ERROR 70100: Query execution was interrupted
set debug_sync='RESET'; set debug_sync='RESET';
drop table t1,t2,t3; drop table t2,t3;
...@@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; 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 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 1 SIMPLE t2 ref c c 5 test.t1.a 2
DROP TABLE t1, t2; DROP TABLE t1, t2;
create table t1 ( create table t1 (
...@@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee'); ...@@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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 EXPLAIN
SELECT t3.a FROM t1,t2,t3 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 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'); ...@@ -3690,7 +3690,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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; 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 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 ); CREATE TABLE t2 ( f11 int PRIMARY KEY );
...@@ -3767,11 +3767,11 @@ COUNT(*) ...@@ -3767,11 +3767,11 @@ COUNT(*)
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; 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 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); ...@@ -3781,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; 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 id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -3532,7 +3532,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -3532,7 +3532,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; 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 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 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; DROP TABLE t1, t2;
create table t1 ( create table t1 (
...@@ -3693,7 +3693,7 @@ t3.c IN ('bb','ee'); ...@@ -3693,7 +3693,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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 EXPLAIN
SELECT t3.a FROM t1,t2,t3 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 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'); ...@@ -3701,7 +3701,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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; 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 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 ); CREATE TABLE t2 ( f11 int PRIMARY KEY );
...@@ -3778,11 +3778,11 @@ COUNT(*) ...@@ -3778,11 +3778,11 @@ COUNT(*)
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; 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 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); ...@@ -3792,7 +3792,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; 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 id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -3521,7 +3521,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN EXPLAIN
SELECT a, c, d, f FROM t1,t2 WHERE a=c AND b BETWEEN 4 AND 6 AND a > 0; 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 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 1 SIMPLE t2 ref c c 5 test.t1.a 2
DROP TABLE t1, t2; DROP TABLE t1, t2;
create table t1 ( create table t1 (
...@@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee'); ...@@ -3682,7 +3682,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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 EXPLAIN
SELECT t3.a FROM t1,t2,t3 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 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'); ...@@ -3690,7 +3690,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 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 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; 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 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 ); CREATE TABLE t2 ( f11 int PRIMARY KEY );
...@@ -3767,11 +3767,11 @@ COUNT(*) ...@@ -3767,11 +3767,11 @@ COUNT(*)
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null IS NULL; 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 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); ...@@ -3781,7 +3781,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ; 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 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 EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ; 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 id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -1892,7 +1892,7 @@ WHERE A.a=t1.a AND t2.b < 20); ...@@ -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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 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 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
...@@ -1904,7 +1904,7 @@ WHERE A.a=t1.a AND t2.b < 20); ...@@ -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 id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 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 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_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2; drop table t1,t2;
......
...@@ -1899,7 +1899,7 @@ WHERE A.a=t1.a AND t2.b < 20); ...@@ -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 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 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 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; 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 id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
...@@ -1911,7 +1911,7 @@ WHERE A.a=t1.a AND t2.b < 20); ...@@ -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 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 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 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_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2; drop table t1,t2;
......
...@@ -217,7 +217,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -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 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 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 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 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 1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where
select o_year, select o_year,
......
...@@ -126,7 +126,6 @@ order by o_year; ...@@ -126,7 +126,6 @@ order by o_year;
eval EXPLAIN $Q8; eval EXPLAIN $Q8;
eval $Q8; eval $Q8;
let $Q9= let $Q9=
select nation, o_year, sum(amount) as sum_profit select nation, o_year, sum(amount) as sum_profit
from (select n_name as nation, from (select n_name as nation,
......
...@@ -341,7 +341,7 @@ WHERE Language='English' AND Percentage > 10 AND ...@@ -341,7 +341,7 @@ WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra 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 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 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; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
......
...@@ -348,7 +348,7 @@ WHERE Language='English' AND Percentage > 10 AND ...@@ -348,7 +348,7 @@ WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra 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 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 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; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
......
...@@ -343,7 +343,7 @@ WHERE Language='English' AND Percentage > 10 AND ...@@ -343,7 +343,7 @@ WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra 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 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 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; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
......
...@@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240 ...@@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
ORDER BY c1 ORDER BY c1
LIMIT 1; LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra 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; DROP TABLE t1;
# #
# #
......
...@@ -5130,13 +5130,13 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num) ...@@ -5130,13 +5130,13 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num)
cost of sweep 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) bool add_time_for_compare)
{ {
DBUG_ENTER("get_sweep_read_cost"); DBUG_ENTER("get_sweep_read_cost");
#ifndef OLD_SWEEP_COST #ifndef OLD_SWEEP_COST
handler *file= param->table->file; 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; double cost;
if (add_time_for_compare) if (add_time_for_compare)
{ {
...@@ -5420,7 +5420,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, ...@@ -5420,7 +5420,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
/* Calculate cost(rowid_to_row_scan) */ /* Calculate cost(rowid_to_row_scan) */
{ {
/* imerge_cost already includes WHERE_COST */ /* 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; imerge_cost+= sweep_cost;
trace_best_disjunct. trace_best_disjunct.
add("rows", non_cpk_scan_records). add("rows", non_cpk_scan_records).
...@@ -5572,7 +5572,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, ...@@ -5572,7 +5572,7 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
roru_total_cost= (roru_index_costs + roru_total_cost= (roru_index_costs +
rows2double(roru_total_records)*log((double)n_child_scans) * rows2double(roru_total_records)*log((double)n_child_scans) *
ROWID_COMPARE_COST_THD(param->thd) / M_LN2 + 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", DBUG_PRINT("info", ("ROR-union: cost %g, %zu members",
roru_total_cost, n_child_scans)); roru_total_cost, n_child_scans));
...@@ -6523,7 +6523,7 @@ bool check_index_intersect_extension(THD *thd, ...@@ -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 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. 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->cost= cost;
next->length= curr->length+1; next->length= curr->length+1;
...@@ -7197,8 +7197,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info, ...@@ -7197,8 +7197,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
DBUG_PRINT("info", ("info->total_cost: %g", info->total_cost)); DBUG_PRINT("info", ("info->total_cost: %g", info->total_cost));
if (!info->is_covering) if (!info->is_covering)
{ {
double sweep_cost= get_sweep_read_cost(info->param, double sweep_cost= get_sweep_read_cost(info->param, info->out_rows, 1);
double2rows(info->out_rows), 1);
info->total_cost+= sweep_cost; info->total_cost+= sweep_cost;
trace_costs->add("disk_sweep_cost", sweep_cost); trace_costs->add("disk_sweep_cost", sweep_cost);
DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost)); DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost));
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
using and calling Rowid_filter_sorted_array::check() from the engine 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_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 Average disk seek time on a hard disk is 8-10 ms, which is also
......
...@@ -33,7 +33,7 @@ lookup_cost(Rowid_filter_container_type cont_type) ...@@ -33,7 +33,7 @@ lookup_cost(Rowid_filter_container_type cont_type)
{ {
switch (cont_type) { switch (cont_type) {
case SORTED_ARRAY_CONTAINER: 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: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
return 0; return 0;
...@@ -161,9 +161,9 @@ Range_rowid_filter_cost_info::build_cost(Rowid_filter_container_type cont_type) ...@@ -161,9 +161,9 @@ Range_rowid_filter_cost_info::build_cost(Rowid_filter_container_type cont_type)
switch (cont_type) { switch (cont_type) {
case SORTED_ARRAY_CONTAINER: case SORTED_ARRAY_CONTAINER:
/* Add cost of filling container and cost of sorting */ /* Add cost of filling container and cost of sorting */
cost= (est_elements * cost+= (est_elements *
(costs->rowid_copy_cost + // Copying rowid (costs->rowid_copy_cost + // Copying rowid
costs->rowid_cmp_cost * log2(est_elements))); // Sort costs->rowid_cmp_cost * log2(est_elements))); // Sort
break; break;
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment