Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Counting propositions

Re: Counting propositions

From: --CELKO-- <jcelko212_at_earthlink.net>
Date: 20 Jun 2004 16:41:46 -0700
Message-ID: <18c7b3c2.0406201541.470bf024@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 Sun Jun 20 2004 - 18:41:46 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US