mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00: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:
commit
99634d4c05
1 changed files with 10 additions and 12 deletions
|
@ -322,9 +322,9 @@ class acp_search
|
||||||
{
|
{
|
||||||
$sql = 'SELECT post_id, poster_id, forum_id
|
$sql = 'SELECT post_id, poster_id, forum_id
|
||||||
FROM ' . POSTS_TABLE . '
|
FROM ' . POSTS_TABLE . '
|
||||||
WHERE post_id >= ' . (int) ($post_counter + 1) . '
|
WHERE post_id > ' . (int) $post_counter . '
|
||||||
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
|
ORDER BY post_id ASC';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query_limit($sql, $this->batch_size);
|
||||||
|
|
||||||
$ids = $posters = $forum_ids = array();
|
$ids = $posters = $forum_ids = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -339,14 +339,13 @@ class acp_search
|
||||||
if (count($ids))
|
if (count($ids))
|
||||||
{
|
{
|
||||||
$this->search->index_remove($ids, $posters, $forum_ids);
|
$this->search->index_remove($ids, $posters, $forum_ids);
|
||||||
|
$post_counter = $ids[count($ids) - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_counter += $this->batch_size;
|
|
||||||
}
|
}
|
||||||
// save the current state
|
// save the current state
|
||||||
$this->save_state();
|
$this->save_state();
|
||||||
|
|
||||||
if ($post_counter <= $this->max_post_id)
|
if ($post_counter < $this->max_post_id)
|
||||||
{
|
{
|
||||||
$totaltime = microtime(true) - $starttime;
|
$totaltime = microtime(true) - $starttime;
|
||||||
$rows_per_second = $row_count / $totaltime;
|
$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
|
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
|
||||||
FROM ' . POSTS_TABLE . '
|
FROM ' . POSTS_TABLE . '
|
||||||
WHERE post_id >= ' . (int) ($post_counter + 1) . '
|
WHERE post_id > ' . (int) $post_counter . '
|
||||||
AND post_id <= ' . (int) ($post_counter + $this->batch_size);
|
ORDER BY post_id ASC';
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query_limit($sql, $this->batch_size);
|
||||||
|
|
||||||
$buffer = $db->sql_buffer_nested_transactions();
|
$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']);
|
$this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
|
||||||
}
|
}
|
||||||
$row_count++;
|
$row_count++;
|
||||||
|
$post_counter = $row['post_id'];
|
||||||
}
|
}
|
||||||
if (!$buffer)
|
if (!$buffer)
|
||||||
{
|
{
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_counter += $this->batch_size;
|
|
||||||
}
|
}
|
||||||
// save the current state
|
// save the current state
|
||||||
$this->save_state();
|
$this->save_state();
|
||||||
|
@ -434,7 +432,7 @@ class acp_search
|
||||||
$this->search->tidy();
|
$this->search->tidy();
|
||||||
$config['num_posts'] = $num_posts;
|
$config['num_posts'] = $num_posts;
|
||||||
|
|
||||||
if ($post_counter <= $this->max_post_id)
|
if ($post_counter < $this->max_post_id)
|
||||||
{
|
{
|
||||||
$totaltime = microtime(true) - $starttime;
|
$totaltime = microtime(true) - $starttime;
|
||||||
$rows_per_second = $row_count / $totaltime;
|
$rows_per_second = $row_count / $totaltime;
|
||||||
|
|
Loading…
Add table
Reference in a new issue