NOT IN ('val4')
is basically equivalent to
WHERE
NOT (column = 'val4') /* or column <> 'val4' */
whereas IN ('val1', 'val2', 'val3')
is basically equivalent to
WHERE
(
column = 'val1'
OR
column = 'val2'
OR
column = 'val3'
)
I would hope that the first option is faster, if only negligibly. The SQL engine might optimize IN
differently depending on how many values you specify in the IN
function and what indexes are available on your table. What behavior are you seeing that you're questioning the method to use?