Skip to content
Snippets Groups Projects
Commit 2ab505d6 authored by Jared Hancock's avatar Jared Hancock Committed by Peter Rotich
Browse files

search: Significantly speed up re-indexing

This significantly speeds up the re-indexing speed for large databases. Since it is
only important to have the system reindexed--and not necessarily what order the
re-indexing happends, the sorting is really just a waste of resources and time.

This dramatically increases the performance of searching for indexable threads, for
instance, from 260900ms to about 42ms.
parent 81b1e9d7
No related branches found
No related tags found
No related merge requests found
......@@ -481,7 +481,7 @@ class MysqlSearchBackend extends SearchBackend {
LEFT JOIN `".TABLE_PREFIX."_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='H')
WHERE A2.`object_id` IS NULL AND (A1.poster <> 'SYSTEM')
AND (LENGTH(A1.`title`) + LENGTH(A1.`body`) > 0)
ORDER BY A1.`id` DESC LIMIT 500";
LIMIT 500";
if (!($res = db_query_unbuffered($sql, $auto_create)))
return false;
......@@ -501,7 +501,7 @@ class MysqlSearchBackend extends SearchBackend {
$sql = "SELECT A1.`ticket_id` FROM `".TICKET_TABLE."` A1
LEFT JOIN `".TABLE_PREFIX."_search` A2 ON (A1.`ticket_id` = A2.`object_id` AND A2.`object_type`='T')
WHERE A2.`object_id` IS NULL
ORDER BY A1.`ticket_id` DESC LIMIT 300";
LIMIT 300";
if (!($res = db_query_unbuffered($sql, $auto_create)))
return false;
......@@ -524,8 +524,7 @@ class MysqlSearchBackend extends SearchBackend {
$sql = "SELECT A1.`id` FROM `".USER_TABLE."` A1
LEFT JOIN `".TABLE_PREFIX."_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='U')
WHERE A2.`object_id` IS NULL
ORDER BY A1.`id` DESC";
WHERE A2.`object_id` IS NULL";
if (!($res = db_query_unbuffered($sql, $auto_create)))
return false;
......@@ -550,8 +549,7 @@ class MysqlSearchBackend extends SearchBackend {
$sql = "SELECT A1.`id` FROM `".ORGANIZATION_TABLE."` A1
LEFT JOIN `".TABLE_PREFIX."_search` A2 ON (A1.`id` = A2.`object_id` AND A2.`object_type`='O')
WHERE A2.`object_id` IS NULL
ORDER BY A1.`id` DESC";
WHERE A2.`object_id` IS NULL";
if (!($res = db_query_unbuffered($sql, $auto_create)))
return false;
......@@ -575,8 +573,7 @@ class MysqlSearchBackend extends SearchBackend {
require_once INCLUDE_DIR . 'class.faq.php';
$sql = "SELECT A1.`faq_id` FROM `".FAQ_TABLE."` A1
LEFT JOIN `".TABLE_PREFIX."_search` A2 ON (A1.`faq_id` = A2.`object_id` AND A2.`object_type`='K')
WHERE A2.`object_id` IS NULL
ORDER BY A1.`faq_id` DESC";
WHERE A2.`object_id` IS NULL";
if (!($res = db_query_unbuffered($sql, $auto_create)))
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment