diff options
author | rxu <rxu@mail.ru> | 2011-01-24 00:01:18 +0700 |
---|---|---|
committer | rxu <rxu@mail.ru> | 2011-01-24 00:01:18 +0700 |
commit | ab9d4b3b638ca02d026dc23574a88d510e5d2291 (patch) | |
tree | 89747a47fd224a36924000c16ff895b0cc540051 | |
parent | ba5c7d8e63d97650989c2866c20c11f16f4c1128 (diff) | |
download | forums-ab9d4b3b638ca02d026dc23574a88d510e5d2291.tar forums-ab9d4b3b638ca02d026dc23574a88d510e5d2291.tar.gz forums-ab9d4b3b638ca02d026dc23574a88d510e5d2291.tar.bz2 forums-ab9d4b3b638ca02d026dc23574a88d510e5d2291.tar.xz forums-ab9d4b3b638ca02d026dc23574a88d510e5d2291.zip |
[ticket/8779] Slow search for 'View unread posts'
Adjust SQL query to speedup search for unread posts (thanks naderman).
PHPBB3-8779
-rw-r--r-- | phpBB/includes/functions.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 65b9f22d12..9a8cc5d6b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1698,7 +1698,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s if ($config['load_db_lastread'] && $user->data['is_registered']) { // Get list of the unread topics - $last_mark = $user->data['user_lastmark']; + $last_mark = (int) $user->data['user_lastmark']; $sql_array = array( 'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time', @@ -1717,10 +1717,11 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s ), 'WHERE' => " + t.topic_last_post_time > $last_mark AND ( (tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.topic_last_post_time > ft.mark_time) OR - (tt.mark_time IS NULL AND ft.mark_time IS NULL AND t.topic_last_post_time > $last_mark) + (tt.mark_time IS NULL AND ft.mark_time IS NULL) ) $sql_extra $sql_sort", |