• Resolved kk4uga

    (@kk4uga)


    Hello, I have the following code on pages of my site. The code shows a list of related posts by TAG.

    My site, which is on a fast dedicated server, gets very busy on certain days and goes unresponsive. I’m wondering if this code is querying the database too much.

    Can someone look at it and see if it looks ok? Thx.

    [Code moderated as per the Forum Rules. Please use the pastebin]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter kk4uga

    (@kk4uga)

    Here is the link to the code:

    https://pastebin.com/QBvERmLY

    Thread Starter kk4uga

    (@kk4uga)

    The reason I am asking is because of this from the WordPress codex:

    If you use query_posts within a template page, WordPress will have already executed the database query and retrieved the records by the time it gets to your template page (that’s how it knew which template page to serve up!). So when you over-ride the default query with query_posts(), you’re essentially throwing away the default query and its results and re-executing another query against the database.

    This is not necessarily a problem, especially if you’re dealing with a smaller blog-based site. Developers of large sites with big databases and heavy visitor traffic may wish to consider alternatives, such as modifying the default request directly (before it’s called). The request filter can be used to achieve exactly this.

    The ‘parse_query’ and the ‘pre_get_posts’ filters are also available to modify the internal $query object that is used to generate the SQL to query the database.

    I don’t see anything in that code that would place a significant strain on the database.

    Thread Starter kk4uga

    (@kk4uga)

    Thanks. Would limiting the number of posts to “get” improve performance? Right now it’s unlimited, but at most it would pull 30-40 posts.

    You commanded to wordpress to include 200 terms in your calling. At least the performance of your site will get poorer…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is this code for related posts slowing down my site?’ is closed to new replies.