[ACCEPTED]-Performance of COUNT SQL function-aggregate
Accepted answer
Performance should not matter because they 2 do 2 different aggregates
COUNT(*)
is all rows, including NULLsCOUNT(some_column_name)
, excludes NULL in "some_column_name
"
See the "Count(*) vs Count(1)" question 1 for more
Option 2 actually counts all the fields 7 where some_column_name
is not null. Option 1 counts all 6 the fields where any field is not null. So 5 you might actually get different results 4 out of these two queries. Most of the time 3 you actually want to count all the rows, and 2 then the fastest option, which does not 1 check for any of the fields, is simply SELECT COUNT(1) FROM ...
No, there is no performance gain in Sql 1 Server.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.