Is there a performance hit using COUNT(*) over COUNT开发者_StackOverflow社区(attributeName) in T-SQL
If attributeName
is nullable, these are different constructs which yield different results, since COUNT()
does not count NULL
values.
The attributeName
should be fetched and evaluated in the latter case.
If it's not (and defined as NOT NULL
), then there is no performance difference and they are optimized to use the same plan.
They are different queries so performance shouldn't matter...
But COUNT only looks at NULL vs NON-NULL expressions
精彩评论