mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/16940] Optimize phpBB Native Search
- Use `sql_query_limit` instead of `sql_query` - Update SQL query to reflect the above change - Assign proper last `post_id` to `$post_counter` PHPBB3-16940
This commit is contained in:
parent
391e4943d9
commit
65fa73855c
1 changed files with 6 additions and 9 deletions
|
@ -322,9 +322,8 @@ 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);
|
$result = $db->sql_query_limit($sql, $this->batch_size);
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$ids = $posters = $forum_ids = array();
|
$ids = $posters = $forum_ids = array();
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
@ -341,7 +340,7 @@ class acp_search
|
||||||
$this->search->index_remove($ids, $posters, $forum_ids);
|
$this->search->index_remove($ids, $posters, $forum_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_counter += $this->batch_size;
|
$post_counter = end($ids);
|
||||||
}
|
}
|
||||||
// save the current state
|
// save the current state
|
||||||
$this->save_state();
|
$this->save_state();
|
||||||
|
@ -393,9 +392,8 @@ 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);
|
$result = $db->sql_query_limit($sql, $this->batch_size);
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$buffer = $db->sql_buffer_nested_transactions();
|
$buffer = $db->sql_buffer_nested_transactions();
|
||||||
|
|
||||||
|
@ -416,13 +414,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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue