• I am having some problems with performance of my Worpdress installation and after doing some database monitoring this query has been shown to be the worst performer of the lot

    SELECT SQL_CALC_FOUND_ROWS  wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish')  ORDER BY wp_posts.ID ASC LIMIT 0, 1

    Does anyone know what is calling this query and how I can optimise it somehow?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Judging by the ‘LIMIT 0,1’, the query is coming from some place requesting the most recent post.

    I am surprised that this is the worst query. It is a very simple query and should perform well unless you have a very large number of posts.

    The only possible optimization would be to add a filter to remove the ‘SQL_CALC_FOUND_ROWS’ field. To see if it would be worthwhile, run the query in phpMyAdmin (or a similar tool) with and without it. Of course, the value of that may be used in the code, and removing it would break something.

    Thread Starter GavinMannion

    (@gavinmannion)

    It’s not the longest running query but it is being called all the time and I can’t think why this particular query is constantly being called and from where.

    So it may not be the query itself but rather what is calling it

    Look through the code for ‘showposts’ or ‘posts_per_page’ being assigned a value of 1.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Where does this query come from?’ is closed to new replies.