From bd8071bb3350927215cc303292a762c19f4866a1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 5 Oct 2013 04:49:22 -0700 Subject: [PATCH] Add a `(dst, type, src)` key to Differential's edge table Summary: Ref T1279. This came to me in a dream. The existing `differential_relationship` table has an `(objectPHID, type)` column, which theoretically is useful for queries like "revisions with X as a reviewer". In practice, I'm not sure it gets used much, but I can get it to show up in at least some query plans. Add a similar index to the `edge` table. This sequences //before// D7227, which actually migrates the data. Test Plan: - Ran `bin/storage upgrade`. - EXPLAIN'd a bunch of queries against different versions of the schema, this seemed helpful overall. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1279 Differential Revision: https://secure.phabricator.com/D7232 Conflicts: src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php --- resources/sql/patches/20131004.dxedgekey.sql | 2 ++ .../storage/patch/PhabricatorBuiltinPatchList.php | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 resources/sql/patches/20131004.dxedgekey.sql diff --git a/resources/sql/patches/20131004.dxedgekey.sql b/resources/sql/patches/20131004.dxedgekey.sql new file mode 100644 index 0000000000..82bc066e4e --- /dev/null +++ b/resources/sql/patches/20131004.dxedgekey.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_differential.edge + ADD UNIQUE KEY `key_dst` (dst, type, src); diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 80fdf50cc0..84f72cc5d5 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1652,6 +1652,14 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130929.filepolicy.sql'), ), + '20131004.dxedgekey.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20131004.dxedgekey.sql'), + ), + '20131004.dxreviewers.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20131004.dxreviewers.php'), + ), ); } }