2
SELECT * FROM table_master WHERE column_id = 123
SELECT * FROM table_master WHERE column_id IN(456) 

MSSQL execute above queries as follow.

SELECT * FROM table_master WHERE column_id = 123
SELECT * FROM table_master WHERE column_id = 456

By checking execution plan in MSSQL it looks similar to me for time difference.

But When I execute above queries there is bit time difference in MySQL.

SELECT * FROM table_master WHERE column_id = 123 -- 0.000 sec / 0.000 sec
SELECT * FROM table_master WHERE column_id IN(456) -- 0.016 sec / 0.000 sec

So what you guys suggesting for the MySQL? = and IN internally works same in MySQL? or I should use = in case of single value.

Tiny
  • 27,221
  • 105
  • 339
  • 599
Vicky Thakor
  • 3,847
  • 7
  • 42
  • 67
  • http://stackoverflow.com/questions/9926433/mysql-performance-in-clause-vs-equals-for-a-single-value – Surabhil Sergy Nov 18 '14 at 04:56
  • 2
    For such small time values a single execution is meaningless. Did you execute both multiple (say 1000) times in a loop? Did you also make sure you used the same values (not 123 and then 456) for both tests? – Matti Virkkunen Nov 18 '14 at 04:57
  • What if we have multiple users working at the same time? – Vicky Thakor Nov 18 '14 at 05:11
  • @VickyThakor which is why they asked the question. – EternalHour Nov 18 '14 at 05:12
  • 1
    I did few test and came to conclusion that It doesn't matter and the question http://stackoverflow.com/questions/9926433/mysql-performance-in-clause-vs-equals-for-a-single-value supports that. – Vicky Thakor Nov 18 '14 at 05:20

0 Answers0