1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-02 14:47:37 +03:00

MDEV-17752: Plan changes from hash_index_merge to index_merge with new optimizer defaults

The code in best_access_path function, when it does not find a key suitable for ref access
and join_cache_level is set to a value so that hash_join is possible we build a hash key.
Later in the function we compare the cost of ref access with table scan (or index scan
or quick selects). No need to do this when we have got the hash key.
This commit is contained in:
Varun Gupta
2019-05-20 17:44:55 +05:30
parent aaa920dad3
commit 6dbc2ab8b3
4 changed files with 69 additions and 2 deletions

View File

@ -967,6 +967,40 @@ SELECT City.Name, Country.Name, Country.PopulationBar FROM City,Country
set join_cache_level=default;
set join_buffer_size=default;
--echo #
--echo # MDEV-17752: Plan changes from hash_index_merge to index_merge with new optimizer defaults
--echo #
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_use_stat_tables=@@use_stat_tables;
set optimizer_use_condition_selectivity=4;
set use_stat_tables='preferably';
use world;
set join_cache_level=4;
CREATE INDEX City_Name ON City(Name);
--disable_result_log
ANALYZE TABLE City, Country;
--enable_result_log
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND City.Population > 5000000
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
EXPLAIN
SELECT Country.Name, Country.Population, City.Name, City.Population
FROM Country LEFT JOIN City
ON City.Country=Country.Code AND
(City.Population > 5000000 OR City.Name LIKE 'Za%')
WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set @@use_stat_tables=@save_use_stat_tables;
set join_cache_level=default;
DROP DATABASE world;
use test;