Thursday, June 27, 2013

Performance issue with ISNULL function

A condition on a where clause (or a join) that checks if a column IS NULL is likely to trigger a full table scan (if your column is not indexed and depending on which version of SQL server are you running). It does not mater is you use the ISNULL() function, the COALESCE() function, or [column name] IS NULL.


My suggestion is to avoid the use of NULLs in flag columns. If you cannot set your IsActive flag to False (preferaly 0) for NULL values, you might want to consider that logic does not necessarily have to be binary (true or false, 1 or 0), you can have ternary logic (1 = true, 0 = False, 9 = something else like NULL).


Kind regards,


M



No comments:

Post a Comment