Commit c2959178 authored by sergefp@mysql.com's avatar sergefp@mysql.com

Fix for BUG#10037

* Add 0.01 to cost of 'range'+'using index' scan to avoid optimizer choice races with 
  'index' scan.
parent ab0ff534
...@@ -256,12 +256,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2); ...@@ -256,12 +256,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3; explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
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 t2 ref j1 j1 4 const 1 Using index 1 SIMPLE t2 ref j1 j1 4 const 1 Using index
1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index 1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index
explain select * from t1 force index(i1), t2 force index(j1) where explain select * from t1 force index(i1), t2 force index(j1) where
(t1.key1 <t2.keya + 1) and t2.keya=3; (t1.key1 <t2.keya + 1) and t2.keya=3;
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 t2 ref j1 j1 4 const 1 Using index 1 SIMPLE t2 ref j1 j1 4 const 1 Using index
1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index 1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int(11) default NULL, a int(11) default NULL,
......
...@@ -2257,7 +2257,8 @@ inline double get_index_only_read_time(const PARAM* param, ha_rows records, ...@@ -2257,7 +2257,8 @@ inline double get_index_only_read_time(const PARAM* param, ha_rows records,
param->table->file->ref_length) + 1); param->table->file->ref_length) + 1);
read_time=((double) (records+keys_per_block-1)/ read_time=((double) (records+keys_per_block-1)/
(double) keys_per_block); (double) keys_per_block);
return read_time; /* Add 0.01 to avoid cost races between 'range' and 'index' */
return read_time + 0.01;
} }
...@@ -7912,6 +7913,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void) ...@@ -7912,6 +7913,8 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */ file->extra(HA_EXTRA_KEYREAD); /* We need only the key attributes */
result= file->ha_index_init(index); result= file->ha_index_init(index);
result= file->index_last(record); result= file->index_last(record);
if (result == HA_ERR_END_OF_FILE)
DBUG_RETURN(0);
if (result) if (result)
DBUG_RETURN(result); DBUG_RETURN(result);
if (quick_prefix_select && quick_prefix_select->reset()) if (quick_prefix_select && quick_prefix_select->reset())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment