"Stembridge, Michael" <[EMAIL PROTECTED]> wrote on 03/14/2005 02:18:25 
PM:

> I noticed another listmember used COUNT(fieldname) instead of COUNT(*). 
> 
> Is there a noticeable performance increase with COUNTing a column name
> instead of all columns?   (ie, like SELECTing specific columns instead 
of
> using SELECT *)
> 
> Thanks!
> 


COUNT() only counts non-null values. A long time ago, I once had a table 
where every column could have been null (yes it was a bad design but I was 
much younger then). COUNT(*) did not count those rows that were COMPLETELY 
NULL. I haven't tested this recently so I no longer know if it's still 
true (and it wasn't a MySQL database I was using, either)

More on topic...if you say COUNT(fieldname), you say that you want to 
count all of the non-null values in that column. Is it faster than 
select(*)? Probably not but you are asking for something different when 
you phrase your question that way, aren't you. You are asking "how many 
non-null values are in this column" and not "how many rows are not null". 

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to