From d819ee343a3a6dc6282f709e67454cd2f0d1afcf Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 17 May 2010 21:14:02 +0800 Subject: [ticket/9606] Optimize unread search option. Get rid of redundant SQL query in search.php that should increase performance slightly. PHPBB3-9606 --- phpBB/search.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'phpBB/search.php') diff --git a/phpBB/search.php b/phpBB/search.php index 7a9ab82f93..1e1e42d01f 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -387,18 +387,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - $unread_list = array(); - $unread_list = get_unread_topics($user->data['user_id'], $sql_where, $sql_sort); - - if (!empty($unread_list)) - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . " - $sql_sort"; - $field = 'topic_id'; - } break; case 'newposts': @@ -476,6 +464,13 @@ if ($keywords || $author || $author_id || $search_id || $submit) $total_match_count = sizeof($id_ary) + $start; $id_ary = array_slice($id_ary, 0, $per_page); } + else if ($search_id == 'unreadposts') + { + $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $start, $start)); + + $total_match_count = sizeof($id_ary) + $start; + $id_ary = array_slice($id_ary, 0, $per_page); + } else { $search_id = ''; -- cgit v1.2.1