June 24, 2002 at 9:04 am
OK silly question but waht is the performance differnec between COUNT(*) and COUNT(1) if any and why
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
June 24, 2002 at 9:45 am
I've never seen a difference documented for SQL Server. In Oracle count(1) is much faster because count(*) enumerates all the columns in a table before counting the rows. It is possible that SQL Server has the same preprocessor column enumeration with count(*) and not with count(1).
I try to use count(1) as a best practice.
DanW
June 25, 2002 at 1:20 am
Thanks Dan. that's waht I thought, to be honest I've not noticed any performance gain using count(1) in SQLSERVER. I've seen a gain using the ROWS column from SYSINDEXES, but it can often give slightly different results
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply