Task #101707
closedAdd index for column "channel" in table sys_log
100%
Description
This is a pretty time-consuming query when there are a lot of rows in sys_log - and no index present.
SELECT DISTINCT `channel` FROM `sys_log` ORDER BY `channel` ASC
EXPLAIN SELECT DISTINCT `channel` FROM `sys_log` ORDER BY `channel` ASC;
sys_log---
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---: | --- | --- | --- | --- | --- | --- | --- | --- | ---: | ---: | --- |
1 | SIMPLE | sys_log | \N | ALL | \N | \N | \N | \N | 15126595 | 100.00 | Using temporary; Using filesort |
Same applies to this query:
SELECT DISTINCT `level` FROM `sys_log`;
I am not reviewing the PHP code here.
Just adding the proper index for each query already helps to reduce query execution-time from up to 200seconds down to some milliseconds.
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80570
Updated by Ingo Fabbri over 1 year ago
After indexes added:
sys_log---
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---: | --- | --- | --- | --- | --- | --- | --- | --- | ---: | ---: | --- |
1 | SIMPLE | sys_log | \N | range | channel | channel | 82 | \N | 5 | 100.00 | Using index for group-by |
Updated by Ingo Fabbri over 1 year ago
Before:
SELECT DISTINCT `channel` FROM `sys_log` ORDER BY `channel` ASC; /* Affected rows: 0 Found rows: 5 Warnings: 0 Duration for 1 query: 00:01:40.0 */
After:
SELECT DISTINCT `channel` FROM `sys_log` ORDER BY `channel` ASC; /* Affected rows: 0 Found rows: 5 Warnings: 0 Duration for 1 query: 0.022 sec. */
Updated by Ingo Fabbri over 1 year ago
Comparison for `level` looks mostly the same.
Updated by Gerrit Code Review over 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80660
Updated by Anonymous over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 5753be96cfbf642a18b5761f759eb9e67ce86e47.