Page MenuHomePhabricator

D14505.id35091.diff
No OneTemporary

D14505.id35091.diff

diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
--- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
+++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
@@ -41,9 +41,10 @@
$rows = queryfx_all(
$conn_r,
- 'SELECT * FROM %T %Q ORDER BY id DESC %Q',
+ 'SELECT * FROM %T %Q %Q %Q',
$task_table->getTableName(),
$this->buildWhereClause($conn_r),
+ $this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
return $task_table->loadAllFromArray($rows);
@@ -83,6 +84,18 @@
return $this->formatWhereClause($where);
}
+ private function buildOrderClause(AphrontDatabaseConnection $conn_r) {
+ // NOTE: The garbage collector executes this query with a date constraint,
+ // and the query is inefficient if we don't use the same key for ordering.
+ // See T9808 for discussion.
+
+ if ($this->dateCreatedBefore) {
+ return qsprintf($conn_r, 'ORDER BY dateCreated DESC, id DESC');
+ } else {
+ return qsprintf($conn_r, 'ORDER BY id DESC');
+ }
+ }
+
private function buildLimitClause(AphrontDatabaseConnection $conn_r) {
$clause = '';
if ($this->limit) {

File Metadata

Mime Type
text/plain
Expires
Fri, May 10, 8:44 AM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6281868
Default Alt Text
D14505.id35091.diff (1 KB)

Event Timeline