Re: Seven-fold performance regression with maria-5.3-dsmrr-cpk
Trying on the latest 5.3-dsmrr-cpk and 5.3-main, compiled with BUILD/compile-pentium-max, I got this:
5.3-main
--------
MariaDB [bug637160]> explain SELECT table1 . `col_int_key` AS field1 FROM ( E AS table1 STRAIGHT_JOIN ( ( DD AS table2 INNER JOIN E AS table3 ON (table3 . `col_int_nokey` = table2 . `pk` ) ) ) ON (table3 . `col_varchar_nokey` > table2 . `col_varchar_key` ) ) LIMIT 8786;
-----------------------------------------------------------------------------------------------------------------------+
| id |
select_type |
table |
type |
possible_keys |
key |
key_len |
ref |
rows |
Extra |
-----------------------------------------------------------------------------------------------------------------------+
| 1 |
SIMPLE |
table1 |
index |
NULL |
col_int_key |
5 |
NULL |
1251 |
Using index |
| 1 |
SIMPLE |
table3 |
ALL |
NULL |
NULL |
NULL |
NULL |
1251 |
Using join buffer |
| 1 |
SIMPLE |
table2 |
eq_ref |
PRIMARY,col_varchar_key |
PRIMARY |
4 |
bug637160.table3.col_int_nokey |
1 |
Using where |
-----------------------------------------------------------------------------------------------------------------------+
(The same with @@join_cache_level=6)
Average query execution time is 0.22 sec
5.3-dsmrr-cpk
-------------
MariaDB [bug637160]> explain SELECT table1 . `col_int_key` AS field1 FROM ( E AS table1 STRAIGHT_JOIN ( ( DD AS table2 INNER JOIN E AS table3 ON (table3 . `col_int_nokey` = table2 . `pk` ) ) ) ON (table3 . `col_varchar_nokey` > table2 . `col_varchar_key` ) ) LIMIT 8786;
-----------------------------------------------------------------------------------------------------------------------+
| id |
select_type |
table |
type |
possible_keys |
key |
key_len |
ref |
rows |
Extra |
-----------------------------------------------------------------------------------------------------------------------+
| 1 |
SIMPLE |
table1 |
index |
NULL |
col_int_key |
5 |
NULL |
874 |
Using index |
| 1 |
SIMPLE |
table3 |
ALL |
NULL |
NULL |
NULL |
NULL |
874 |
Using join buffer |
| 1 |
SIMPLE |
table2 |
eq_ref |
PRIMARY,col_varchar_key |
PRIMARY |
4 |
bug637160.table3.col_int_nokey |
1 |
Using where |
-----------------------------------------------------------------------------------------------------------------------+
MariaDB [bug637160]> set join_cache_level=6;
Query OK, 0 rows affected (0.00 sec)
MariaDB [bug637160]> explain SELECT table1 . `col_int_key` AS field1 FROM ( E AS table1 STRAIGHT_JOIN ( ( DD AS table2 INNER JOIN E AS table3 ON (table3 . `col_int_nokey` = table2 . `pk` ) ) ) ON (table3 . `col_varchar_nokey` > table2 . `col_varchar_key` ) ) LIMIT 8786;
------------------------------------------------------------------------------------------------------------------------------------+
| id |
select_type |
table |
type |
possible_keys |
key |
key_len |
ref |
rows |
Extra |
------------------------------------------------------------------------------------------------------------------------------------+
| 1 |
SIMPLE |
table1 |
index |
NULL |
col_int_key |
5 |
NULL |
874 |
Using index |
| 1 |
SIMPLE |
table3 |
ALL |
NULL |
NULL |
NULL |
NULL |
874 |
Using join buffer |
| 1 |
SIMPLE |
table2 |
eq_ref |
PRIMARY,col_varchar_key |
PRIMARY |
4 |
bug637160.table3.col_int_nokey |
1 |
Using where; Using join buffer |
------------------------------------------------------------------------------------------------------------------------------------+
Query execution times:
join_cache_level=default: 0.22 sec (same as in 5.3-main)
join_cache_level=6: 1.89 sec
If one sets mrr_sort_keys=off, then DS-MRR/CPK gets disabled, and execution
plan becomes the same as in 5.3-main, or with join_cache_level=default, with the same query time within 0.20 ...0.25 sec range.
mysqldump of tables and data
LPexportBug637160_bug637160.sql.zip