• Hello,

    I’m using WordPress for photoarchive of WWII – http://waralbum.ru.
    There are 31000+ posts on the site, every post is tagged with multiple tags.

    The problem is, that lists of posts for tags are generated very slow due to a big amount of posts. For example, tag “americans” – http://waralbum.ru/tag/американцы/ – contanins 4150+ posts and page for it (paged 10 posts for a page) genereates over 2 minutes.

    Some tags return server error “502” until I increase server timeouts.

    So, my question is: why tags are so slow and how can I optimize it? As for categories – with thousands of posts they are genereted very quickly.

    My be I just can limit the number of posts that is returned for tag page to 500 or 1000? How can I do that?

    • This topic was modified 7 years, 2 months ago by kusachiy.
    • This topic was modified 7 years, 2 months ago by kusachiy.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’ve no explanation. Aside from a different term ID, the tag queries are identical to category queries. There may be some sort of caching involved so that the category query results already exist in a cache.

    The results returned are already limited to the posts per page, so that limitation is not going to help. I think the slowdown is because the query includes SQL_CALC_FOUND_ROWS because WP wants to be able to properly handle pagination. It needs to know how many results there are in total in order to know what the last page is. If you’re willing forgo accurate pagination, this portion can be removed using the “posts_request” filter. It may take more patching since WP is not getting what it expects for results, but at least you can see if this even helps with query speed or not.

    It may just be you need more server resources than you currently have, or the database needs to be optimized in some way. These sort of things are beyond my skill set, but I know WP can handle extremely large databases with the proper resources and optimization. For example, these forums have nearly 9 million posts and similar queries often take less than 10 seconds. Of course, this site is on hardcore enterprise level servers so it’s not a fair comparison. It does illustrate that huge datasets are manageable with the right resources.

    Thread Starter kusachiy

    (@kusachiy)

    Tnank you very much for detailed reply!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit posts for tag output’ is closed to new replies.