I am trying to decide on which approach to take in a database I am designing.
I will be adding a ProcessedDate datetime null
column in a table. It will be nullable for when the record has not been processed.
So, is it worth having a Processed bit not null default 0
column as well?
With the following queries:
select * from tablename where ProcessedDate is null
and
select * from tablename where Processed = 0
All things being equal*, what is the performance difference between the two versions?
*: Appropriate indices are applied to the table in each version. I am not looking for advice on what indices to create. I only want information about the performance of the filter as applied to a single row. If all rows in the table need to be scanned, or a seek is done is irrelevant to the question at hand.
I know that an argument could be made that having the Processed flag is more explicit and therefore more readable, however it also raises issues around keeping the columns in sync (which could be handled by using a computed column). Anyway, I want to limit the scope of this question to the performance side of things.