Title: Reducing database queries
Last modified: August 19, 2016

---

# Reducing database queries

 *  [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/)
 * Hi,
 * I have a custom post type (‘faculty_profile) and a custom taxonomy (‘departments’).
   On a page that lists all of the faculty profiles, it groups them by department.
   That page generates approximately 600-700 database queries. Given the large number
   of queries, I am pretty sure there are ways I can make the page more efficient.
   Do you have any ideas?
 * My code:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com)]_
 * What am I doing wrong?
 * Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/#post-1839691)
 * Using transients for each department didn’t seem to help much.
 * There are about 220 posts of the faculty_profile post type.
 * We’ll be using WP Super Cache, so there won’t necessarily be 700 db queries for
   each page load. But, I’d still like to improve this.
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/#post-1839712)
 * Here’s the code, which was removed by a moderator.
 * [http://wordpress.pastebin.com/jZX7Ev3k](http://wordpress.pastebin.com/jZX7Ev3k)
 * Thanks for your help.
 *  [Brian Layman](https://wordpress.org/support/users/brianlayman/)
 * (@brianlayman)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/#post-1839748)
 * That’s tough…
 * I recommend something like w3_total_cache with memcache or even better APC installed.
   w3tc will not only give you page caching, but will give you object caching so
   that your queries won’t hit the database most of the time the are called on a
   variant of your page that has not yet been loaded.
 * Simple page caching would still cause those pages to be processed when someone
   is logged in and hits that page or perhaps after a comment has been left. So 
   you want an object cache to keep the results of the query executions in memory
   too.
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/#post-1839894)
 * Thanks Brian. I will give w3_total_cache a try.
 * We have experimented with WP Super Cache’s “Directly Cached Files” features and
   this works, even if it is a little more brute force than we’d like.
 * I was hoping I was simply missing some obvious techniques to reduce the number
   of queries!

Viewing 4 replies - 1 through 4 (of 4 total)

 The topic ‘Reducing database queries’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/reducing-database-queries/#post-1839894)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
