Re: Counting propositions

From: --CELKO-- <jcelko212_at_earthlink.net>
Date: 20 Jun 2004 16:41:46 -0700
Message-ID: <18c7b3c2.0406201541.470bf024_at_posting.google.com>


>> Speaking of that, I've seen several examples where the writer puts
 SELECT COUNT(1) FROM source WHERE (predicate); I've always wondered whether there are any consequences to that usage, other than readability? <<

History. COUNT(*) and EXISTS (SELECT * ..) originally meant "pick one column" and not "pick all the columns"; SQL aggregates were defined for columnar subqueries only. But they were also defined only for non-NULLs. So we had to make it a weird exception to behavior for COUNT(*). Unfortunately, some early SQLs (i.e. Oracle) expanded the subquery in its full glory. What COUNT(<constant>) did was tell early optimizers they did not have to look at the whole row. Received on Mon Jun 21 2004 - 01:41:46 CEST

Original text of this message