Link to home
Start Free TrialLog in
Avatar of gotaquestion
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.
Avatar of CRagsdell
CRagsdell

I ran both queries through Query Analyzer against a rather large database, and got faster response time from COUNT(*) than COUNT(0).

Try running both queries in your database using Query Analyzer and review the statistics.

CR


ASKER CERTIFIED SOLUTION
Avatar of vjammy
vjammy
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
for most tables this is the fastest way to get rowcount:
select rowcnt from sysindexes where id= object_id ('myTable')