var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: count(1) versus count(*)
Have a very simple and basic question...
Can somebody point out in detail what the differences are between
count(1) and count(*) ??
select count(1) from <table>
select count(*) from <table>
Which is better to use, why, limitations etc ..
Thanks a lot!
Doesn't matter. You should probably stick to COUNT( * ) for clarity -- because that is what you really mean.
Don't think this is entirely correct.
I believe count(1) is inherently quicker...since the Sybase projection doesn't involve any columns of the table, and "1" serves as a constant value projection.
The count(*) leads to a projection of all the columns of the table and hence leads to greater overhead.
Have you heard of any explanation similar to the above??
Are there any other differences??
Thanks a lot.
Also...any idea on my other "isql help" post??
I have read in DB2 that count(1) performs better than count(*). Still looking for same comparison in Sybase.
Look at the showplan and statistics I/O. You'll see that they're the same. The optimizer isn't
Didn't think of that
Also if you do not need the
exact number of rows you can pull it from a system table (the one that shows when you do sp_help foo). I can't quite remember which one it is.
Here's the ASE manual for how ASE optimizes the count( * ):
Are the query plans different if there is a where clause??