Comment 7 for bug 1052523

Revision history for this message
Elena Stepanova (elenst) wrote : Re: Unexpected index condition pushdown behaviour on range queries

A smaller test case suitable both for MTR and regular server (the original one can also be used):

# Either run in MTR as ./mtr <testname>,
# or start server with all default parameters to see the result for XtraDB,
# and with --ignore-builtin-innodb --innodb --plugin-load=ha_innodb.so to see the result for InnoDB plugin

--source include/have_innodb.inc

CREATE TABLE t1 (i INT NOT NULL, k INT NOT NULL, v CHAR(32), KEY k(k,i)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,3227,'f90dd1afb12d8078da97215431ccaf6e'), (2,7286,'fe2a44fd61aec8c76d71cd2fd5cd0a16');

EXPLAIN SELECT * FROM t1 WHERE k BETWEEN 4000 AND 5000 AND i < 1000 ORDER BY k ASC LIMIT 10;

DROP TABLE t1;

# End of test case

# Result for XtraDB:

+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+
| 1 | SIMPLE | t1 | range | k | k | 8 | NULL | 1 | Using index condition |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+

# Result for InnoDB plugin:

+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | t1 | range | k | k | 8 | NULL | 1 | Using where |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+