Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15478145
D14505.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14505.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 8, 8:46 PM (1 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7737014
Default Alt Text
D14505.diff (1 KB)
Attached To
Mode
D14505: Improve efficiency of worker task GC for huge loads
Attached
Detach File
Event Timeline
Log In to Comment