Stewart
Stewart

Reputation: 1899

Is there a performance difference between using IN ('ABC') and = 'ABC' in MySQL?

Is there a performance difference between the two queries below?

SELECT * FROM mytable WHERE name IN ('ABC');

SELECT * FROM mytable WHERE name = ('ABC');

Upvotes: 2

Views: 74

Answers (2)

Omesh
Omesh

Reputation: 29091

no there is no difference between IN and = for single value. you can check query execution plan using EXPLAIN EXTENDED:

EXPLAIN EXTENDED SELECT * FROM mytable WHERE name IN ('ABC');

SHOW WARNINGS;

Upvotes: 4

Simon
Simon

Reputation: 12488

No. I believe MySQL rewrites x IN (a, b, c) to x = a OR x = b OR x = c internally, so it's the same query.

Upvotes: -1

Related Questions