From 204b6694af1acb2db42723945c9d05b31585895c Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 18 Apr 2012 14:38:23 -0700 Subject: [PATCH] Improve performance of empty search Summary: Searching for empty query kills us because whole `search_document` table is read in this case. This diff adds an index just for this query. Other solution would be to disable searching for empty string. But it can be actually useful (listing newest documents of any type). Test Plan: lang=sql EXPLAIN SELECT document.phid, document.documentType, document.documentTitle, document.documentCreated FROM `search_document` document GROUP BY document.phid ORDER BY documentCreated DESC LIMIT 0, 21; Reviewers: epriestley Reviewed By: epriestley CC: jungejason, aran, Koolvin Differential Revision: https://secure.phabricator.com/D2277 --- resources/sql/patches/134.emptysearch.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 resources/sql/patches/134.emptysearch.sql diff --git a/resources/sql/patches/134.emptysearch.sql b/resources/sql/patches/134.emptysearch.sql new file mode 100644 index 0000000000..40e51cf6b2 --- /dev/null +++ b/resources/sql/patches/134.emptysearch.sql @@ -0,0 +1,2 @@ +ALTER TABLE `phabricator_search`.`search_document` + ADD INDEX `documentCreated` (`documentCreated`);