aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2009-12-23 19:38:09 +0000
committerNils Adermann <naderman@naderman.de>2009-12-23 19:38:09 +0000
commitdd02aed6e129e9c14bcc5c53ce41973c61bdde9e (patch)
tree3ddfbe9b6a95665e1eef0f5ffe0aa108a66adda9
parent38d0f0f2d9459f67225f65981c7f199801898759 (diff)
downloadforums-dd02aed6e129e9c14bcc5c53ce41973c61bdde9e.tar
forums-dd02aed6e129e9c14bcc5c53ce41973c61bdde9e.tar.gz
forums-dd02aed6e129e9c14bcc5c53ce41973c61bdde9e.tar.bz2
forums-dd02aed6e129e9c14bcc5c53ce41973c61bdde9e.tar.xz
forums-dd02aed6e129e9c14bcc5c53ce41973c61bdde9e.zip
Improved search query performance through sorting words by their occurance. [Bug #21555]
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10377 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/docs/CHANGELOG.html1
-rw-r--r--phpBB/includes/search/fulltext_native.php21
2 files changed, 14 insertions, 8 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 7aefdeafc9..267e4e0bff 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -124,6 +124,7 @@
<li>[Fix] Restrict search for styles/../style.cfg to folders. (Bug #55665)</li>
<li>[Fix] Add ability to disable overall (aka board-wide) feed.</li>
<li>[Fix] Do not pass new_link parameter when creating a persistent connection with mysql. (Bug #55785)</li>
+ <li>[Fix] Improved search query performance through sorting words by their occurance. (Bug #21555)</li>
<li>[Change] Move redirect into a hidden field to avoid issues with mod_security. (Bug #54145)</li>
<li>[Change] Log activation through inactive users ACP. (Bug #30145)</li>
<li>[Change] Send time of last item instead of current time in ATOM Feeds. (Bug #53305)</li>
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 5af3929ccd..e1ab02ba9d 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -202,7 +202,8 @@ class fulltext_native extends search_backend
{
$sql = 'SELECT word_id, word_text, word_common
FROM ' . SEARCH_WORDLIST_TABLE . '
- WHERE ' . $db->sql_in_set('word_text', $exact_words);
+ WHERE ' . $db->sql_in_set('word_text', $exact_words) . '
+ ORDER BY word_count ASC';
$result = $db->sql_query($sql);
// store an array of words and ids, remove common words
@@ -377,10 +378,6 @@ class fulltext_native extends search_backend
return false;
}
- sort($this->must_contain_ids);
- sort($this->must_not_contain_ids);
- sort($this->must_exclude_one_ids);
-
if (!empty($this->search_query))
{
return true;
@@ -420,11 +417,19 @@ class fulltext_native extends search_backend
return false;
}
+ $must_contain_ids = $this->must_contain_ids;
+ $must_not_contain_ids = $this->must_not_contain_ids;
+ $must_exclude_one_ids = $this->must_exclude_one_ids;
+
+ sort($must_contain_ids);
+ sort($must_not_contain_ids);
+ sort($must_exclude_one_ids);
+
// generate a search_key from all the options to identify the results
$search_key = md5(implode('#', array(
- serialize($this->must_contain_ids),
- serialize($this->must_not_contain_ids),
- serialize($this->must_exclude_one_ids),
+ serialize($must_contain_ids),
+ serialize($must_not_contain_ids),
+ serialize($must_exclude_one_ids),
$type,
$fields,
$terms,