Skip to content

Commit 3bd0da0

Browse files
author
epriestley
committed
Add a missing table key to improve performance of "Recently Completed Tasks" query
Summary: Fixes T11490. Currently, this query can not use a key and the table size may be quite large. Adjust the query so it can use a key for both selection and ordering, and add that key. Test Plan: Ran `EXPLAIN` on the old query in production, then added the key and ran `EXPLAIN` on the new query. Saw key in use, and "rows" examined drop from 29,273 to 15. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11490 Differential Revision: https://secure.phabricator.com/D16423
1 parent 4d175ac commit 3bd0da0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ private function buildOrderClause(AphrontDatabaseConnection $conn_r) {
104104

105105
if ($this->dateCreatedBefore) {
106106
return qsprintf($conn_r, 'ORDER BY dateCreated DESC, id DESC');
107+
} else if ($this->dateModifiedSince) {
108+
return qsprintf($conn_r, 'ORDER BY dateModified DESC, id DESC');
107109
} else {
108110
return qsprintf($conn_r, 'ORDER BY id DESC');
109111
}

src/infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ protected function getConfiguration() {
3131
'leaseOwner' => array(
3232
'columns' => array('leaseOwner', 'priority', 'id'),
3333
),
34+
'key_modified' => array(
35+
'columns' => array('dateModified'),
36+
),
3437
) + $parent[self::CONFIG_KEY_SCHEMA];
3538

3639
return $config;

0 commit comments

Comments
 (0)