vBulletin query optimization request

Discussion in 'Databases' started by jscieza, Jan 23, 2011.

  1. #1
    Hi guys,

    My programmer gave me the following query to get the latest 10 threads created on my forum to be listed in the sidebar of my forumhome (I'm using vB 3.8.x). Issue here is that the query is being listed as slow query (and a very slow one). Please take a look:

    
        [B]# Query_time: 38  Lock_time: 1        Rows_sent: 10  Rows_examined: 82411[/B]
        SELECT thread.threadid, thread.title, thread.postuserid,     thread.postusername, thread.dateline, thread.replycount
                                FROM vb_thread AS thread
                                LEFT JOIN vb_deletionlog AS deletionlog ON     (deletionlog.primaryid = thread.threadid AND type = 'thread')
                                WHERE open <> 10
                                        AND thread.visible = 1
                                        AND deletionlog.primaryid IS NULL
                                        AND forumid NOT IN     ([B][COLOR=red]a list of 15 forumids goes here[/COLOR][/B])
                                ORDER BY thread.dateline DESC
                                LIMIT 10;
    
    Code (markup):
    How I can optimize that query? Any advice will be more than welcome!

    Thank you,
    Jonathan
     
    jscieza, Jan 23, 2011 IP
  2. mysqlxpert

    mysqlxpert Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Use EXPLAIN(http://dev.mysql.com/doc/refman/5.0/en/explain.html) to identify the bottleneck and post here the output of it. It will be helpful if you can provide the table structure of the tables in question.
     
    mysqlxpert, Jan 24, 2011 IP