1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fixed typo on opt_range.cc: SEL_ARG::number_of_eq_groups()

It could cause wrong range estimation for GROUP BY queries that are
using 'WHERE index_part >= constant'.
(The function was trying to check for 'index_part = constant')

Reporter: Yuty Chaikou
This commit is contained in:
Monty
2023-06-18 12:11:18 +03:00
parent 5fb2c031f7
commit f25a74c0b0
2 changed files with 4 additions and 4 deletions

View File

@ -1375,7 +1375,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index 1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
explain select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a'); explain select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a');
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 idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 1 Using where; Using index for group-by 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 17 Using where; Using index for group-by
explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a'); explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
EXPLAIN EXPLAIN
{ {
@ -1438,11 +1438,11 @@ EXPLAIN
"table_name": "t1", "table_name": "t1",
"access_type": "range", "access_type": "range",
"possible_keys": ["idx_t1_0", "idx_t1_1", "idx_t1_2"], "possible_keys": ["idx_t1_0", "idx_t1_1", "idx_t1_2"],
"key": "idx_t1_1", "key": "idx_t1_2",
"key_length": "147", "key_length": "147",
"used_key_parts": ["a1", "a2", "b"], "used_key_parts": ["a1", "a2", "b"],
"loops": 1, "loops": 1,
"rows": 1, "rows": 17,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"filtered": 100, "filtered": 100,
"attached_condition": "t1.b = 'a' and t1.a1 >= '' and t1.a2 >= 'b'", "attached_condition": "t1.b = 'a' and t1.a1 >= '' and t1.a2 >= 'b'",

View File

@ -11177,7 +11177,7 @@ int SEL_ARG::number_of_eq_groups(uint group_key_parts) const
cur= first(); cur= first();
do do
{ {
if ((cur->min_flag | cur->min_flag) & if ((cur->min_flag | cur->max_flag) &
(NO_MIN_RANGE | NO_MAX_RANGE | NEAR_MIN | NEAR_MAX | GEOM_FLAG)) (NO_MIN_RANGE | NO_MAX_RANGE | NEAR_MIN | NEAR_MAX | GEOM_FLAG))
return -1; return -1;
if (min_value != max_value && !min_max_are_equal()) if (min_value != max_value && !min_max_are_equal())