MySql Slow Query for Wp database

Discussion in 'MySQL' started by tms12, May 19, 2009.

  1. #1
    Hi all,

    Couple of things that i wanted to share before i ask my question:
    - Hostmonster will shut you account if you have any slow query and they will do it without tell you anything.
    - Its a good habit for any webmaster to check your .tmp folder for "slow mysql queries" and "cpu usage" , since if you correct those then you will have a faster speed for your heavy traffic website .
    - DO NOT use, "most popular " plugin . Try use something similar. Its causes all sorts of my sql queries .

    Now the question:
    - After fixing/ deleting "most popular" plugin it fixed the slow queries, and i still get the following cause for "slow mysql query" (see attached pic). Can anyone help me figure out what is cause of that?


    Thanks
     

    Attached Files:

    tms12, May 19, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    First off, I would suggest getting a new host. If you can, get something that allocates you a certain amount of resources, so there's no chance of getting in trouble for using what you have available.

    Second, run an EXPLAIN on the query and post what it comes up with. Run this in a command line.

    
    
    EXPLAIN SELECT SQL_CALC_FOUND_ROWS wp_posts.*FROM wp_posts WHERE 1=1 AND (wp_posts.post_author =1) AND wp_posts.post_type
    (wp_posts.post_status ='publish' ORDER BY wp_posts.post_date DESC LIMIT 0,15;
    
    
    Code (markup):
    Lastly, I would just remove this "1=1 AND". It not necessarily slowing this down, but is useless. Most likely the SQL_CALC_FOUND_ROWS is what's slowing your query down. There's a good chance that two queries would be quicker - http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/.
     
    jestep, May 19, 2009 IP