2007/12/11, Ian Kelly <[EMAIL PROTECTED]>:
> On Dec 11, 2007 4:16 AM, Patryk Zawadzki <[EMAIL PROTECTED]> wrote:
> > Semantics of COUNT require counting all non-NULL values and some more
> > naive databases might actually try to fetch all the columns while 1
> > comes from DUAL and requires no actual data fetching.
> This surprises me if it's true.  count(*) just counts all result rows
> without checking anything for null, whereas count(1) must count all
> rows for which the expression 1 is not null.  count(*) is therefore
> simpler and intuitively easier to optimize.

Actually what you describe is COUNT(1), COUNT(*) has been subject to
such abuse that most database engines actually substitute it with
either COUNT(0) or COUNT(1) in early parsing phases. (This is true for
Postrgres, MySQL, MS SQL and Oracle at least.)

A true COUNT(*) would select each row's data for all columns and then
compare the set with NULL.

I believe COUNT(1) was the correct way to do it even before I was born ;)

-- 
Patryk Zawadzki
PLD Linux Distribution

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to