Code: Select all
mysql> explain SELECT DISTINCT sql_no_cache topic_id FROM phpbb_posts WHERE post_id IN ( 5204899, 5204820, 5156469, 5204521);
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
| 1 | SIMPLE | phpbb_posts | range | PRIMARY | PRIMARY | 3 | NULL | 4 | Using where; Using temporary |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+------------------------------+
Code: Select all
mysql> explain SELECT sql_no_cache topic_id FROM phpbb_posts WHERE post_id IN ( 5204899, 5204820, 5156469, 5204521) group by topic_id;
+----+-------------+-------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| 1 | SIMPLE | phpbb_posts | range | PRIMARY | PRIMARY | 3 | NULL | 4 | Using where; Using temporary; Using filesort |
+----+-------------+-------------+-------+---------------+---------+---------+------+------+----------------------------------------------+
Code: Select all
topic_id: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
topic_page: 1,1,1,1,1,2,2,2,2, 2, 3, 3,3,3, 3, 4
Code: Select all
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
Code: Select all
WHERE t.forum_id = $forum_id
AND t.topic_page = $page_id <-- change here
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
<-- change here, cutted out LIMIT -->
Code: Select all
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s WHERE u.user_id = s.session_user_id AND s.session_time BETWEEN " . ( time() - 300 ) . " AND " . (time()) . " ORDER BY u.username ASC, s.session_ip ASC";