From 6389a576331ad907a3e2c1354963186d59d3d007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dark=E2=9D=B6?= <25451052+Dark1z@users.noreply.github.com> Date: Mon, 13 Dec 2021 19:39:01 +0530 Subject: [PATCH] [ticket/16940] Optimize phpBB Native Search - Use `ORDER BY post_id ASC` for batch posts. PHPBB3-16940 --- phpBB/phpbb/search/backend/base.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/search/backend/base.php b/phpBB/phpbb/search/backend/base.php index ff57189a85..cb2a6e7f39 100644 --- a/phpBB/phpbb/search/backend/base.php +++ b/phpBB/phpbb/search/backend/base.php @@ -452,8 +452,9 @@ abstract class base implements search_backend_interface protected function get_posts_batch_after(int $post_id): \Generator { $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id - FROM ' . POSTS_TABLE . ' - WHERE post_id > ' . $post_id; + FROM ' . POSTS_TABLE . ' + WHERE post_id > ' . (int) $post_id . ' + ORDER BY post_id ASC'; $result = $this->db->sql_query_limit($sql, self::BATCH_SIZE); while ($row = $this->db->sql_fetchrow($result))