From 879431fb504122a23af82354437d534371366a86 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 26 Jul 2011 18:11:54 -0700 Subject: [PATCH] Improve GC performance for Herald Transcripts Summary: This has to table scan a ginormous table right now, give it a fighting chance with a more usable key. Test Plan: - Launched GC daemon, no errors. - Used test console to create a new transcript. - Viewed some old transcripts. - Ran EXPLAIN on the SELECT and verified it was utilizing the garbageCollected key. Reviewed By: jungejason Reviewers: jungejason, tuomaspelkonen, aran CC: aran, epriestley, jungejason Differential Revision: 735 --- resources/sql/patches/069.heraldxscript.sql | 9 +++++++++ .../PhabricatorGarbageCollectorDaemon.php | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 resources/sql/patches/069.heraldxscript.sql diff --git a/resources/sql/patches/069.heraldxscript.sql b/resources/sql/patches/069.heraldxscript.sql new file mode 100644 index 0000000000..753aa44bd1 --- /dev/null +++ b/resources/sql/patches/069.heraldxscript.sql @@ -0,0 +1,9 @@ +ALTER TABLE phabricator_herald.herald_transcript + ADD garbageCollected BOOL NOT NULL DEFAULT 0; + +UPDATE phabricator_herald.herald_transcript + SET garbageCollected = 1 + WHERE objectTranscript = ""; + +ALTER TABLE phabricator_herald.herald_transcript + ADD KEY (garbageCollected, time); diff --git a/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollectorDaemon.php b/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollectorDaemon.php index 4375c08034..4faad2c859 100644 --- a/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollectorDaemon.php +++ b/src/infrastructure/daemon/garbagecollector/PhabricatorGarbageCollectorDaemon.php @@ -104,8 +104,9 @@ class PhabricatorGarbageCollectorDaemon extends PhabricatorDaemon { objectTranscript = "", ruleTranscripts = "", conditionTranscripts = "", - applyTranscripts = "" - WHERE `time` < %d AND objectTranscript != "" + applyTranscripts = "", + garbageCollected = 1 + WHERE garbageCollected = 0 AND `time` < %d LIMIT 100', $table->getTableName(), time() - $ttl);