Project

General

Profile

Actions

Task #56167

closed

Cleanup exec_SELECTcountRows() calls to NOT count *

Added by Michiel Roos about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
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)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #55568: BE: Only make SQL count calls on uid not *ClosedBenni Mack2014-02-01

Actions
Actions #1

Updated by Stefan Froemken about 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

Actions #2

Updated by Michiel Roos about 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 #3

Updated by Wouter Wolters about 10 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF