Actions
Task #56167
closedCleanup exec_SELECTcountRows() calls to NOT count *
Start date:
2014-02-20
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
no-brainer
Sprint Focus:
Description
Replace 18 calls to exec_SELECTcountRows() to not count on all fields, but just on the uid field.
Use:
$GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', $t)
Instead of:
$GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $t)
Updated by Stefan Froemken over 10 years ago
Hello Michiel,
A profiling from one of my servers:
mysql> SHOW profiles; +----------+------------+----------------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+----------------------------------------------------+ | 1 | 0.16667975 | SELECT SQL_NO_CACHE COUNT(*) FROM sys_log | | 2 | 1.16443300 | SELECT SQL_NO_CACHE COUNT(log_data) FROM sys_log | | 3 | 0.27215525 | SELECT SQL_NO_CACHE COUNT(tstamp) FROM sys_log | | 4 | 0.84435400 | SELECT SQL_NO_CACHE COUNT(details_nr) FROM sys_log | | 5 | 0.33745875 | SELECT SQL_NO_CACHE COUNT(userid) FROM sys_log | | 6 | 0.20984375 | SELECT SQL_NO_CACHE COUNT(uid) FROM sys_log | | 7 | 0.13517075 | SELECT SQL_NO_CACHE COUNT(*) FROM sys_log | | 8 | 0.15109600 | SELECT SQL_NO_CACHE COUNT(uid) FROM sys_log | +----------+------------+----------------------------------------------------+ 8 rows in set (0.00 sec)
As you can see COUNT is always faster. Can you provide some profilings, too?
Stefan
Updated by Michiel Roos over 10 years ago
Stefan,
Thank you for doing measurements on this.
It appears that I did not check my facts. This seems to be a myth.
http://stackoverflow.com/questions/6523714/is-select-countcolumn-faster-slower-than-select-count
Please close this issue.
Actions