0

I have a question - what statement will have a better performance on a database table containing ~300 million of records?

This one:

SELECT COL1, COL2, COL3
FROM
TABLE_1
WHERE COL4 IN ("SOMETHING1",
               "SOMETHING2",
               "SOMETHING3",
               "SOMETHING4");

or this one:

SELECT COL1, COL2, COL3
FROM
TABLE_1
WHERE (COL4 = "SOMETHING1" OR
       COL4 = "SOMETHING2" OR
       COL4 = "SOMETHING3" OR
       COL4 = "SOMETHING4");
hc0re
  • 1,806
  • 2
  • 26
  • 61
  • 2
    Check execution plans – Lukasz Szozda Nov 19 '15 at 11:46
  • 4
    I think the consensus is; it doesn't matter. Though it may depend on your DBMS. See: http://stackoverflow.com/questions/3074713/in-vs-or-in-the-sql-where-clause, http://stackoverflow.com/questions/6514906/in-vs-or-of-oracle-which-faster, http://stackoverflow.com/questions/2110715/sql-server-select-in-vs-or, http://stackoverflow.com/questions/15334695/in-clause-versus-or-clause-performance-wise, http://programmers.stackexchange.com/questions/204559/sql-in-versus-or, http://www.webmastersbydesign.com/2008/07/sql-speed-test-in-vs-or/. In future use Google before asking a question. – HoneyBadger Nov 19 '15 at 11:51

0 Answers0