Skip to content

Commit f25a74c

Browse files
committed
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
1 parent 5fb2c03 commit f25a74c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mysql-test/main/explain_json.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ id select_type table type possible_keys key key_len ref rows Extra
13751375
1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
13761376
explain select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a');
13771377
id select_type table type possible_keys key key_len ref rows Extra
1378-
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
1378+
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
13791379
explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
13801380
EXPLAIN
13811381
{
@@ -1438,11 +1438,11 @@ EXPLAIN
14381438
"table_name": "t1",
14391439
"access_type": "range",
14401440
"possible_keys": ["idx_t1_0", "idx_t1_1", "idx_t1_2"],
1441-
"key": "idx_t1_1",
1441+
"key": "idx_t1_2",
14421442
"key_length": "147",
14431443
"used_key_parts": ["a1", "a2", "b"],
14441444
"loops": 1,
1445-
"rows": 1,
1445+
"rows": 17,
14461446
"cost": "COST_REPLACED",
14471447
"filtered": 100,
14481448
"attached_condition": "t1.b = 'a' and t1.a1 >= '' and t1.a2 >= 'b'",

sql/opt_range.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11177,7 +11177,7 @@ int SEL_ARG::number_of_eq_groups(uint group_key_parts) const
1117711177
cur= first();
1117811178
do
1117911179
{
11180-
if ((cur->min_flag | cur->min_flag) &
11180+
if ((cur->min_flag | cur->max_flag) &
1118111181
(NO_MIN_RANGE | NO_MAX_RANGE | NEAR_MIN | NEAR_MAX | GEOM_FLAG))
1118211182
return -1;
1118311183
if (min_value != max_value && !min_max_are_equal())

0 commit comments

Comments
 (0)