Really really slow WordPress query

This query shows up all the time in my slow logs, and I’m just confused about how WP can have such slow queries in it?

FROM wp_posts
WHERE 1 =1
AND post_date_gmt <= '2005-07-07 13:07:51'
post_status = "S"
AND post_status != "w"
GROUP BY wp_posts.ID
ORDER BY post_date DESC
LIMIT 0 , 40

I have a clean WP 2.0.3 install, with no plugings.

The above query regularly takes 100s of seconds to run! Although a regular run when the db is fast seems rather fast (0.0022s). It may be that the query gets slow because of other reasons.

When I run an explain, mysql uses the post_status key, but reports under extra:

Using where; Using temporary; Using filesort

Not so good I believe?

Perhaps comment spam?

0 thoughts on “Really really slow WordPress query

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s