From c0411ae25a792c100216f651ec784c047e7df7fd Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 8 Feb 2015 23:50:45 +0100 Subject: [PATCH] Enhanced SQL query so that the search is faster. --- mod/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/search.php b/mod/search.php index d3cf2b1286..338b377e8d 100644 --- a/mod/search.php +++ b/mod/search.php @@ -130,8 +130,8 @@ function search_content(&$a) { if($tag) { $sql_extra = ""; - $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d) AS `term` ON `item`.`id` = `term`.`oid` ", - dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); + $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` IN (%d, 0)) AS `term` ON `item`.`id` = `term`.`oid` ", + dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user())); $sql_order = "`item`.`id`"; } else {