WordPress slow query

i have a wordpress blog and my shared hosting companny warned me about slow activity.

In my mysql slowlog.log i have essentialy queries that take about 2 an d 3 (i think seconds not milliseconds)

Read More

here is the query in the log :

# Query_time: 2  Lock_time: 0  Rows_sent: 25  Rows_examined: 36266
    SELECT l.ID, post_content, post_name, post_author, post_parent, post_modified_gmt, post_date, post_date_gmt
                    FROM (
                        SELECT ID FROM wp_posts 
                            WHERE post_status = 'publish'
                            AND post_password = ''
                            AND post_type = 'my_post_type'

                            ORDER BY post_modified ASC
                            LIMIT 25 OFFSET 9925 ) o
                        JOIN wp_posts l
                        ON l.ID = o.ID
                        ORDER BY l.ID;

My questions are : is this query a core query ? in this case is it normal to take 3 seconds ? if not, how can i remedy ? i mean by a core query if it is not a plugin or a theme function that generate this query, since i have not found it in the theme’s function.php

I have another slow query in the log :

# Query_time: 2  Lock_time: 0  Rows_sent: 1  Rows_examined: 29232
SELECT post_modified_gmt FROM wp_posts WHERE post_status IN ('publish','inherit') AND post_type = 'my_post_type' ORDER BY post_modified_gmt ASC LIMIT 1 OFFSET 2999;

same questions here, is it a core query or plugin relatedd one etc…

Please note that i’ve installed WP super cache, my site loads faster but i still have these slow queries in slowlog.log

PS: I’m on a reliable hsting company (infomaniak), they have put my blog on Dedicated VPS machine for 15 days to let me fix the problem

Thanks for the help and sorry for my very bad english

——————————————-EDIT—————————————

No way still have these queries after installing wp super cache 🙁

# Query_time: 2  Lock_time: 0  Rows_sent: 25  Rows_examined: 49908
SELECT l.ID, post_content, post_name, post_author, post_parent, post_modified_gmt, post_date, post_date_gmt
                FROM (
                    SELECT ID FROM wp_posts 
                        WHERE post_status = 'publish'
                        AND post_password = ''
                        AND post_type = 'my_post_type'

                        ORDER BY post_modified ASC
                        LIMIT 25 OFFSET 23550 ) o
                    JOIN wp_posts l
                    ON l.ID = o.ID
                    ORDER BY l.ID;

Related posts

Leave a Reply

3 comments

  1. Okay i’ve found what was the problem for these queries :

    First there are NOT CORE queries they were generated by a plugin which is called “Yoast WordPress SEO” precisally the sitemap part of the plugin. “file : class-sitemaps.php”

    When i disabled the sitemap part of the plugin, i didn’t had these queries in my slowlog.log file.

  2. I am getting this as slow query where this query will hit

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

    actually i manually set posts_per_pages to 16,