mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-34993, part2: backport optimizer_adjust_secondary_key_costs
...and make the fix for MDEV-34993 switchable. It is enabled by default and controlled with @optimizer_adjust_secondary_key_costs=fix_card_multiplier
This commit is contained in:
@ -280,7 +280,61 @@ JS
|
||||
}
|
||||
}
|
||||
]
|
||||
# Disable the fix and try the same:
|
||||
set @@optimizer_adjust_secondary_key_costs='';
|
||||
explain select * from t1
|
||||
where
|
||||
pk in (1,2,3,4,5) and
|
||||
key1 <= 4;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL 5 Using where
|
||||
drop table t1;
|
||||
# Shows a high multiplier, without a "note":
|
||||
select
|
||||
json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS
|
||||
from
|
||||
information_schema.optimizer_trace;
|
||||
JS
|
||||
[
|
||||
[
|
||||
{
|
||||
"index_name": "PRIMARY",
|
||||
"selectivity_from_index": 0.005
|
||||
},
|
||||
{
|
||||
"index_name": "key1",
|
||||
"selectivity_from_index": 0.399,
|
||||
"selectivity_multiplier": 90.9091
|
||||
}
|
||||
]
|
||||
]
|
||||
# Includes 1.79...e308 as cost:
|
||||
select
|
||||
json_detailed(json_extract(trace,'$**.best_access_path')) as JS
|
||||
from
|
||||
information_schema.optimizer_trace;
|
||||
JS
|
||||
[
|
||||
{
|
||||
"considered_access_paths":
|
||||
[
|
||||
{
|
||||
"access_type": "range",
|
||||
"resulting_rows": 181.3636545,
|
||||
"cost": 1.79769e308,
|
||||
"chosen": true
|
||||
}
|
||||
],
|
||||
"chosen_access_method":
|
||||
{
|
||||
"type": "range",
|
||||
"records": 181.3636545,
|
||||
"cost": 1.79769e308,
|
||||
"uses_join_buffering": false
|
||||
}
|
||||
}
|
||||
]
|
||||
set optimizer_adjust_secondary_key_costs=default;
|
||||
#
|
||||
# Clean up
|
||||
#
|
||||
|
Reference in New Issue
Block a user