[TYPO3-core] RFC: Bug #10099: Use TYPO3_DB->exec_SELECTcountRows() to determine the number of rows

Oliver Hader oliver at typo3.org
Mon Jan 12 19:12:49 CET 2009


Hi Dmitry,

Dmitry Dulepov schrieb:
> Oliver Hader wrote:
>> In the TYPO Core counting rows is/was implemented as the following:
>> * get result set for a "COUNT(*)" query, fetch row, free result set (not
>> in all cases)
>> * get result set for a regular table SELECT, get sql_num_rows, free
>> result set (not in all cases again)
>>
>> Solution:
>> To prevent hanging record sets here and simplify the code,
>> TYPO3_DB->exec_SELECTcountRows() is going to be used.
> 
> Some of the calls use '*'. others use 'uid'. Is there any special reason for such differences?

Exactly... COUNT(<fieldname>) is faster than COUNT(*) - however the
fieldname has to be non-NULL, otherwise COUNT() will give a wrong
result. I used the fieldname where I could be sure, that there is that
fieldname and that it is not NULL.

I've read that COUNT(1) should work as well but didn't find a proper
explanation what happens there internally on the DBMS...

olly
-- 
Oliver Hader
TYPO3 4.3 Release Manager


More information about the TYPO3-team-core mailing list