[TYPO3-dev] Tip: use SQL function COUNT(*)

ries van Twisk typo3 at rvt.dds.nl
Fri Jul 18 16:35:13 CEST 2008


On Jul 18, 2008, at 9:14 AM, Martin Kutschker wrote:

> ries van Twisk schrieb:
>>
>> Also keep in mind that in some databases counting is much more  
>> expensive
>> then counting in MySQL with MyISAM tables.
>
> But I don't beleive that counting server side is more expensive than
> client side for any DB.

You are absolutely right in that! Best is to count it server side.

>
>
> But of course it doesn't make sense to do a COUNT(*) to decide if you
> should do a full select with *exactly* the same WHERE statement. I've
> seen that too. In this case the DB has to do the same work twice.

Fully agreed!!!


I just wanted to explain that count(*) (cardinality counting) is  
different
from count(field) (expression counting).

Also that counting in general is fast on MyISAM (but in-accurate under  
some conditions)
and can be much slower for InnoDB or other DB engines.

But you are right Masi, if you need to do a count on a set of records,  
then count(..) is your friend
and not to retrieve a data set and count on the client side

Ries

>
>
> Masi
>
> _______________________________________________






More information about the TYPO3-dev mailing list