[dba-SQLServer] Timeout

Stuart McLachlan stuart at lexacorp.com.pg
Fri Aug 20 20:33:28 CDT 2004


On 20 Aug 2004 at 20:24, Arthur Fuller wrote:

> I can't verify the internals but I agree with your suggestion. Almost
> all SQL books suggest that Count(*) is highly optimized while
> Count(MyField) is not.
> 

SQLBOL
<quote>
COUNT(*) returns the number of items in a group, including NULL values and 
duplicates.

COUNT(ALL expression) evaluates expression for each row in a group and 
returns the number of nonnull values.
</quote>

Count(*) just does a row scan. Count(Field) needs to compare the value of 
Field to Null in every row.


-- 
Stuart





More information about the dba-SQLServer mailing list