WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site with more than 300,000 posts (but really little posts) and cheking why is going so slow I've seen that in the hompage it makes something like this:

"Generated in 15.024 seconds. Made 9492 queries to database and 0 cached queries. Memory used - 81.12MB"

Home only displays the first 10 psts and runs a couple of twitter plugins, any idea about how to reduce this massive amount of queries?


share|improve this question
"I have a site with more than 300,000 posts (but really little posts)" ?! Try this plugin to see what queries are being made, maybe dump them on pastebin, so we can see that too. – onetrickpony Sep 26 '11 at 15:58

Delete post/page revisions and that will reduce queries as well as the overall size of the DB. Run this in phpmyadmin (backup the DB first):

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'

Change table prefix above if needed. And run optimize from phpmyadmin afterward.

Add this to wp-config.php to prevent revisions from accumulating again:

define ('WP_POST_REVISIONS', 0);

See http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions

And use that plugin pointed out above to see what else is querying the DB.

share|improve this answer

Two other ideas:

  1. What Plugins are you using? Some Plugins are especially database-intensive, such as related-content type Plugins.

  2. What is your permalink structure? If the site has several posts/pages, and is using %postname alone as the permalink structure, you could be invoking verbose rewrite rules, resulting in a LOT of db queries.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.