XF 2.2 Slow running query?

ekool

Well-known member
I have a site that is pretty heavily modified and definitely has a lot of attachments. Does anyone know what might be running this query? It could be an add-on as well. I'm looking to speed it up, the query can take upwards of 45 seconds sometimes.

Code:
EXPLAIN SELECT xf_attachment.attachment_id, xf_attachment.content_type, xf_attachment.content_id, xf_attachment_data.data_id FROM xf_attachment INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id INNER JOIN xf_post ON xf_post.post_id = xf_attachment.content_id INNER JOIN xf_thread ON xf_thread.thread_id = xf_post.thread_id WHERE xf_attachment.content_type = ? AND xf_attachment.content_id > ? AND xf_attachment_data.filename NOT LIKE ? AND xf_attachment_data.height >= ? AND xf_post.message_state = ? AND (xf_thread.node_id = 36 OR xf_thread.node_id = 50 OR xf_thread.node_id = 112) ORDER BY RAND() LIMIT ?:

I told mytop to explain it but that didn't really give me much.

Edit: Tracked it down, it is the AndyB Featured Images plugin.

Code:
                // get results
                $results = $db->fetchAll("
                SELECT xf_attachment.attachment_id,
                xf_attachment.content_type,
                xf_attachment.content_id,
                xf_attachment_data.data_id
                FROM xf_attachment
                INNER JOIN xf_attachment_data ON xf_attachment_data.data_id = xf_attachment.data_id
                INNER JOIN xf_post ON xf_post.post_id = xf_attachment.content_id
                INNER JOIN xf_thread ON xf_thread.thread_id = xf_post.thread_id
                WHERE xf_attachment.content_type = ?
                AND xf_attachment.content_id > ?
                AND xf_attachment_data.filename NOT LIKE ?
                AND xf_attachment_data.height >= ?
                AND xf_post.message_state = ?
                $whereclause
                ORDER BY RAND()
                LIMIT ?
                ", array('post', '0', '%.gif%', $minimumHeight, 'visible', $limitWide));
 
Last edited:
Back
Top Bottom