mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
BUG#16166, "Can't use index_merge with FORCE INDEX": adjust the heurstics check to take into
account that "FORCE INDEX" disables full table scans, and not range/index_merge scans. (with post-review fixes)
This commit is contained in:
@ -384,3 +384,21 @@ max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.ke
|
||||
8186
|
||||
set join_buffer_size= @save_join_buffer_size;
|
||||
drop table t0, t1, t2, t3, t4;
|
||||
CREATE TABLE t1 (
|
||||
cola char(3) not null, colb char(3) not null, filler char(200),
|
||||
key(cola), key(colb)
|
||||
);
|
||||
INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ');
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
8704
|
||||
explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 24 Using intersect(cola,colb); Using where
|
||||
explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 24 Using intersect(cola,colb); Using where
|
||||
drop table t1;
|
||||
|
@ -327,3 +327,33 @@ set join_buffer_size= @save_join_buffer_size;
|
||||
|
||||
drop table t0, t1, t2, t3, t4;
|
||||
|
||||
# BUG#16166
|
||||
CREATE TABLE t1 (
|
||||
cola char(3) not null, colb char(3) not null, filler char(200),
|
||||
key(cola), key(colb)
|
||||
);
|
||||
INSERT INTO t1 VALUES ('foo','bar', 'ZZ'),('fuz','baz', 'ZZ');
|
||||
|
||||
--disable_query_log
|
||||
let $1=9;
|
||||
while ($1)
|
||||
{
|
||||
eval INSERT INTO t1 SELECT * from t1 WHERE cola = 'foo';
|
||||
dec $1;
|
||||
}
|
||||
|
||||
let $1=13;
|
||||
while ($1)
|
||||
{
|
||||
eval INSERT INTO t1 SELECT * from t1 WHERE cola <> 'foo';
|
||||
dec $1;
|
||||
}
|
||||
|
||||
--enable_query_log
|
||||
|
||||
OPTIMIZE TABLE t1;
|
||||
select count(*) from t1;
|
||||
explain select * from t1 WHERE cola = 'foo' AND colb = 'bar';
|
||||
explain select * from t1 force index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
|
||||
drop table t1;
|
||||
|
||||
|
Reference in New Issue
Block a user