• 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. Please use the pastebin]

    What am I doing wrong?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Bill Dennen

    (@xyzzy)

    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

    (@xyzzy)

    Here’s the code, which was removed by a moderator.

    https://wordpress.pastebin.com/jZX7Ev3k

    Thanks for your help.

    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

    (@xyzzy)

    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.