gotaquestion
asked on
count(*) vs count(0)
Is there any performance gains by using count(0) vs count(*) when getting the total row count of a table?
Someone suggested count(0) is faster because it doesn't count all the columns in the table only the first column.
Someone suggested count(0) is faster because it doesn't count all the columns in the table only the first column.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
for most tables this is the fastest way to get rowcount:
select rowcnt from sysindexes where id= object_id ('myTable')
select rowcnt from sysindexes where id= object_id ('myTable')
Try running both queries in your database using Query Analyzer and review the statistics.
CR