WordPress.org

Ready to get started?Download WordPress

Forums

Reducing database queries (5 posts)

  1. Bill Dennen
    Member
    Posted 3 years ago #

    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.

  2. Bill Dennen
    Member
    Posted 3 years ago #

    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.

  3. Bill Dennen
    Member
    Posted 3 years ago #

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

    http://wordpress.pastebin.com/jZX7Ev3k

    Thanks for your help.

  4. Brian Layman
    Member
    Posted 3 years ago #

    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.

  5. Bill Dennen
    Member
    Posted 3 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.