Task #56167
closed
Cleanup exec_SELECTcountRows() calls to NOT count *
Added by Michiel Roos over 10 years ago.
Updated over 10 years ago.
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)
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
- Status changed from New to Closed
Also available in: Atom
PDF