diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-04-11 13:49:32 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-04-11 13:49:32 +0000 |
commit | 0319733ea8e9dd5225fc9169bb3a063bf29bcd9c (patch) | |
tree | 92f0a6be76547b6f624d177fafe12b43446e4c21 | |
parent | 77fcc367e2ec60a1ca9a891d6cbcbf48be05badb (diff) | |
download | forums-0319733ea8e9dd5225fc9169bb3a063bf29bcd9c.tar forums-0319733ea8e9dd5225fc9169bb3a063bf29bcd9c.tar.gz forums-0319733ea8e9dd5225fc9169bb3a063bf29bcd9c.tar.bz2 forums-0319733ea8e9dd5225fc9169bb3a063bf29bcd9c.tar.xz forums-0319733ea8e9dd5225fc9169bb3a063bf29bcd9c.zip |
[Change] Performance improvements for native fulltext search (patch by Paul)
(This has been tested for 2 weeks in a live environment)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9440 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/docs/CHANGELOG.html | 5 | ||||
-rw-r--r-- | phpBB/includes/search/fulltext_native.php | 22 |
2 files changed, 22 insertions, 5 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 782559bec2..5d4c775895 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -137,15 +137,16 @@ <li>[Fix] Enforce correct case for template variables</li> <li>[Fix] Set topic_last_view_time on post/reply/edit to circumvent race conditions in auto prune and false removal of topics for manual forum prune (Bug #18055, #43515)</li> <li>[Fix] Correctly split long subject lines according to the used RFC. This fixes extra spaces within long subjects. (Bug #43715)</li> - <li>[Change] Allow download of conflicting file for later reference in automatic updater</li> <li>[Change] Default difference view is now 'inline' instead of 'side by side'</li> <li>[Change] Added new option for merging differences to conflicting files in automatic updater</li> - <li>[Change] Added new options for visual confirmation.</li> <li>[Change] Add link to user profile in the MCP for user notes and warn user.</li> <li>[Change] Add IN_PHPBB check to generated cache files. (reported by bantu)</li> <li>[Change] Add topic icons to prosilver UCP main and subscribed templates (Bug #42735 - Patch by Raimon)</li> <li>[Change] Add unique key to ACL options table to prevent duplicate permission options. (Bug #41835)</li> <li>[Change] Redirect to relevant MCP page of multi-page topic if accessing quickmod tools (Split option for example)</li> + <li>[Change] Performance improvements for native fulltext search (patch by Paul)</li> + <li>[Feature] Added new options for visual confirmation.</li> + <li>[Feature] Allow download of conflicting file for later reference in automatic updater</li> <li>[Feature] Allow translation of custom BBCode help messages. (Patch by bantu)</li> <li>[Feature] db_tools now support create table and drop table.</li> <li>[Feature] Database updater checks for incompatible db schema (MySQL 3.x/4.x against MySQL 4.1.x/5.x/6.x)</li> diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index ee36039454..5a9f34a261 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -650,8 +650,12 @@ class fulltext_native extends search_backend case 'mysql4': case 'mysqli': + $sql_array_copy = $sql_array; + // 3.x does not support SQL_CALC_FOUND_ROWS - $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; + // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT']; + $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id '; + $is_mysql = true; break; @@ -730,8 +734,14 @@ class fulltext_native extends search_backend } // if we use mysql and the total result count is not cached yet, retrieve it from the db - if (!$total_results && $is_mysql) + if (!$total_results && $is_mysql && !empty($sql_array_copy)) { + $sql = $db->sql_build_query('SELECT', $sql_array_copy); + unset($sql_array_copy); + + $db->sql_query($sql); + $db->sql_freeresult($result); + $sql = 'SELECT FOUND_ROWS() as total_results'; $result = $db->sql_query($sql); $total_results = (int) $db->sql_fetchfield('total_results'); @@ -855,7 +865,7 @@ class fulltext_native extends search_backend { case 'mysql4': case 'mysqli': - $select = 'SQL_CALC_FOUND_ROWS ' . $select; +// $select = 'SQL_CALC_FOUND_ROWS ' . $select; $is_mysql = true; break; @@ -948,6 +958,12 @@ class fulltext_native extends search_backend if (!$total_results && $is_mysql) { + // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. + $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); + + $db->sql_query($sql); + $db->sql_freeresult($result); + $sql = 'SELECT FOUND_ROWS() as total_results'; $result = $db->sql_query($sql); $total_results = (int) $db->sql_fetchfield('total_results'); |