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

[ticket/9606] Optimize unread search option.

Get rid of redundant SQL query in search.php that should increase performance slightly.

PHPBB3-9606
This commit is contained in:
rxu
2010-05-17 21:14:02 +08:00
parent 6d7e30ae99
commit d819ee343a
2 changed files with 11 additions and 15 deletions

View File

@@ -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 = '';