Re: Why does this query take so long to load

vendredi 27 juin 2014

I have a modified messageindex.php and this is the main query for it (down). It sometimes takes up to 10 seconds to load!SELECT

t.ID_TOPIC, t.numReplies, t.locked, t.numViews, t.isSticky, t.ID_POLL,

IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from,

t.ID_LAST_MSG, ml.posterTime AS lastPosterTime, ml.ID_MSG_MODIFIED,

ml.subject AS lastSubject, ml.icon AS lastIcon, ml.posterName AS lastMemberName,

ml.ID_MEMBER AS lastID_MEMBER, IFNULL(meml.realName, ml.posterName) AS lastDisplayName,

att.ID_ATTACH, att.attachmentType, att.filename, meml.avatar,

t.ID_FIRST_MSG, mf.posterTime AS firstPosterTime,

mf.subject AS firstSubject, mf.icon AS firstIcon, mf.posterName AS firstMemberName,

mf.ID_MEMBER AS firstID_MEMBER, IFNULL(memf.realName, mf.posterName) AS firstDisplayName,

LEFT(ml.body, 384) AS lastBody, LEFT(mf.body, '200') AS firstBody, ml.smileysEnabled AS lastSmileys,

mf.smileysEnabled AS firstSmileys

, IFNULL(big.ID_ATTACH, 0) AS bigId, big.filename AS bigFilename, big.width AS bigWidth, big.height AS bigHeight,

IFNULL(thn.ID_ATTACH, 0) AS thnId, thn.filename AS thnFilename, thn.width AS thnWidth, thn.height AS thnHeight

, trl.rate

FROM (smf_topics AS t, smf_messages AS ml, smf_messages AS mf)

LEFT JOIN smf_tr_log as trl ON (t.ID_TOPIC = trl.ID_TOPIC)

LEFT JOIN smf_attachments AS big ON (big.ID_MSG = mf.ID_MSG AND big.attachmentType = 0)

LEFT JOIN smf_attachments AS thn ON (thn.ID_ATTACH = big.ID_THUMB)

LEFT JOIN smf_members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)

LEFT JOIN smf_members AS memf ON (memf.ID_MEMBER = mf.ID_MEMBER)

LEFT JOIN smf_log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = 27)

LEFT JOIN smf_log_mark_read AS lmr ON (lmr.ID_BOARD = 8 AND lmr.ID_MEMBER = 27)



LEFT JOIN smf_attachments AS att ON (att.ID_MEMBER = meml.ID_MEMBER)

WHERE t.ID_BOARD = 8

AND ml.ID_MSG = t.ID_LAST_MSG

AND mf.ID_MSG = t.ID_FIRST_MSG





GROUP BY t.ID_TOPIC

ORDER BY isSticky DESC, ID_LAST_MSG DESC

LIMIT 0, 40




What could be the culprit here?


0 commentaires:

Enregistrer un commentaire

 

Lorem

Ipsum

Dolor