Bug #19123 Not using index with "IN"-Keyword

Submitted: 16 Apr 2006 1:09 Modified: 17 Apr 2006 1:58
Reporter: Timo Stripf Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.11-Debian_4sarge2-log OS:Linux (linux debian)
Assigned to: CPU Architecture:Any

[16 Apr 2006 1:09] Timo Stripf
Description:
The mysql server does not use indices if the IN-Keyword is used in WHERE cause.

On the two identical selects the first one uses indices and the second one not:

SELECT * FROM test WHERE a = 1 AND b = 2 OR a = 1 AND b = 4;
SELECT * FROM test WHERE (a,b) IN ((1,2),(1,4));

How to repeat:
CREATE TABLE test (a INT, b INT, c INT, PRIMARY KEY (a,b));

INSERT INTO test (a,b,c) VALUES(1,2,3),(2,3,4);

EXPLAIN SELECT * FROM test WHERE a = 1 AND b = 2 OR a = 1 AND b = 4;
EXPLAIN SELECT * FROM test WHERE (a,b) IN ((1,2),(1,4));
[16 Apr 2006 16:14] Hartmut Holzgraefe
this is most likely a duplicate, can't find the original right now though ...
[17 Apr 2006 1:58] Igor Babaev
This ia a duplicate of bug #16247.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.