Very slow query

To check if the query itself is slow or anything else slows it down, try running your query directly in the database, and have a look at how long it takes there.

<?php echo $GLOBALS['wp_query']->request; ?>

This shows you the latest Query that WordPress ran in your database.

If the query is really slow in the database, try caching the results, running this specific quer only once every hour or so. I usually do this with menus – but it works with anything. Using transients to save the output HTML.

I wrote about this technique here.

If you need different output for different taxonomies, try adding the TermID in the name of the transient.

You could delete the transients either on ‘update_post’ or let them expire after a certain time.

Leave a Comment