A follow-up from my previous post.
Is COUNT(1) faster than COUNT(*)?
No, COUNT(1) is mapped into COUNT(*) early in the QP. From the logic of my previous post, COUNT(1) is always non-null and thus is the same as just doing a COUNT(*). Since it is semantically equivalent to COUNT(*), the QP just maps it to COUNT(*) because it makes things simpler and you can avoid special cases for things like local-global aggregation and moving group bys around joins.
You can actually look at the query plan for "SELECT COUNT(1) from Table;" and see that the output plan is COUNT(*).
You can save it a few instructions by using COUNT(*). You will also make the ANSI SQL gods happier.
I get a lot of questions about these syntax issues – it makes sense, as this is often very interesting in traditional procedural programming languages. In many cases, there are only very minor performance differences, if any, in the SQL language due to these. The big differences happen because your slightly different query actually means something semantically different and thus implies a different amount of work to compute.
Please keep sending in your questions – I'm happy to answer them!
Thanks,
Conor Cunningham