Slow Query with large forum February 08, 2021, 08:29:46 pm I am not sure if this is due to the import or just a issue in general, when clicking on a board and retrieving all the posts it is slow to load. If I drop the attachments of the join and SELECT then it drops to < 0.5s on all my tests. The attachments table is currently empty, I tried adding one attachment to see if that helped but nothing. There is about 393,731 Posts in 136,146 Topics in that board. So not that many, although a fair few. Code: [Select] SELECT t.id_topic, t.num_replies, t.locked, t.num_views, t.num_likes, t.is_sticky, t.id_poll, t.id_previous_board, COALESCE(lt.id_msg, lmr.id_msg, -1) + 1 AS new_from, t.id_last_msg, t.approved, t.unapproved_posts, t.id_redirect_topic, t.id_first_msg, ml.poster_time AS last_poster_time, ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, ml.poster_name AS last_member_name, ml.id_member AS last_id_member, ml.smileys_enabled AS last_smileys, COALESCE(meml.real_name, ml.poster_name) AS last_display_name, mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon, mf.poster_name AS first_member_name, mf.id_member AS first_id_member, mf.smileys_enabled AS first_smileys, COALESCE(memf.real_name, mf.poster_name) AS first_display_name ,meml.avatar,COALESCE(a.id_attach, 0) AS id_attach,a.filename,a.attachment_type,meml.email_addressFROM elkarte_topics AS t INNER JOIN elkarte_messages AS ml ON (ml.id_msg = t.id_last_msg) INNER JOIN elkarte_messages AS mf ON (mf.id_msg = t.id_first_msg) LEFT JOIN elkarte_members AS meml ON (meml.id_member = ml.id_member) LEFT JOIN elkarte_members AS memf ON (memf.id_member = mf.id_member) LEFT JOIN elkarte_log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = 1) LEFT JOIN elkarte_log_mark_read AS lmr ON (lmr.id_board = 8 AND lmr.id_member = 1) LEFT JOIN elkarte_attachments AS a ON (a.id_member = ml.id_member AND a.id_member != 0)WHERE t.id_board = 8ORDER BY is_sticky DESC, t.id_last_msg DESCLIMIT 0, 20in .../sources/subs/MessageIndex.subs.php line 138, which took 16.95581889 seconds at 0.51222014 into request.