1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-02 12:34:59 +02:00

Merge pull request #6347 from DaRk1V0iD/ticket/16940_3.3.x

[ticket/16940] Optimize phpBB Native Search [3.3.x]
This commit is contained in:
Marc Alexander 2021-12-23 22:24:28 +01:00
commit 99634d4c05

View File

@ -322,9 +322,9 @@ class acp_search
{
$sql = 'SELECT post_id, poster_id, forum_id
FROM ' . POSTS_TABLE . '
WHERE post_id >= ' . (int) ($post_counter + 1) . '
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
$result = $db->sql_query($sql);
WHERE post_id > ' . (int) $post_counter . '
ORDER BY post_id ASC';
$result = $db->sql_query_limit($sql, $this->batch_size);
$ids = $posters = $forum_ids = array();
while ($row = $db->sql_fetchrow($result))
@ -339,14 +339,13 @@ class acp_search
if (count($ids))
{
$this->search->index_remove($ids, $posters, $forum_ids);
$post_counter = $ids[count($ids) - 1];
}
$post_counter += $this->batch_size;
}
// save the current state
$this->save_state();
if ($post_counter <= $this->max_post_id)
if ($post_counter < $this->max_post_id)
{
$totaltime = microtime(true) - $starttime;
$rows_per_second = $row_count / $totaltime;
@ -393,9 +392,9 @@ class acp_search
{
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
FROM ' . POSTS_TABLE . '
WHERE post_id >= ' . (int) ($post_counter + 1) . '
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
$result = $db->sql_query($sql);
WHERE post_id > ' . (int) $post_counter . '
ORDER BY post_id ASC';
$result = $db->sql_query_limit($sql, $this->batch_size);
$buffer = $db->sql_buffer_nested_transactions();
@ -416,13 +415,12 @@ class acp_search
$this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
}
$row_count++;
$post_counter = $row['post_id'];
}
if (!$buffer)
{
$db->sql_freeresult($result);
}
$post_counter += $this->batch_size;
}
// save the current state
$this->save_state();
@ -434,7 +432,7 @@ class acp_search
$this->search->tidy();
$config['num_posts'] = $num_posts;
if ($post_counter <= $this->max_post_id)
if ($post_counter < $this->max_post_id)
{
$totaltime = microtime(true) - $starttime;
$rows_per_second = $row_count / $totaltime;