Skip to content

Performance: Slow loading of tags and categories on sites with large amounts #10169

Closed

Description

@tecnogaming

Crowded blog with 100 categories and thousands of tags (750.000 articles).

Trying to add a category gets a delay so big that the showing up of categories can take up to 30 seconds !!. The same thing is happening on tags.

We are using Yoast SEO and we already tried to disable it and it is not the cause. Even when categories and tags are set, trying to "show" the current settings is painful as opening a post could take 30 seconds or more for current categories and tags show up. This lead to many of my writers incorrectly adding repeated tags as they won't show up on time. The VERY AGGRESIVE autosave feature is also something that affects the delay.

Activity

  1. added
    [Type] Performance
    Needs Testing
    on Sep 26, 2018
  2. designsimply commented on Sep 26, 2018

    @designsimply
    Member

    I will work on a way to generate several thousand tags for testing, and this is exactly the kind of issue that opt-in testing helps uncover. I appreciate that you have reported this!

  3. tecnogaming commented on Sep 26, 2018

    @tecnogaming
    Author

    Thanks so much for your reply. Yes, it does seem like Gutenberg is not designed for big blogs as having tons of categories and tags makes it almost impossible to handle. There must be something wrong on the way Gutenberg ask for that information.

  4. danielbachhuber commented on Sep 27, 2018

    @danielbachhuber
    Member

    I will work on a way to generate several thousand tags for testing

    WP-CLI is pretty helpful for this:

    wp term generate category --count=1000
    

    Trying to add a category gets a delay so big that the showing up of categories can take up to 30 seconds !!. The same thing is happening on tags.

    #6694 is potentially related. However, it would be useful to track down whether the source of your slowness is: 1) purely from the amount of data, or 2) caused by some plugin or your theme causing slowness (in addition to the amount of data).

  5. tecnogaming commented on Sep 29, 2018

    @tecnogaming
    Author
  6. websupporter commented on Nov 16, 2018

    @websupporter

    ezgif-2-c8ccf08bc746

    I think the problem is related to the following:
    The current implementation does not use the state management system due to #11643. Currently, this results in a lot of API Requests instead which slows down the whole process.

  7. tecnogaming commented on Nov 16, 2018

    @tecnogaming
    Author
  8. Widhy980 commented on Dec 10, 2018

    @Widhy980

    I also have the same problem, sometimes I type a lot of tags and immediately disappear and re-write again. then I tried to wait for the autocomplete and sometimes it suddenly disappeared. is it possible to use same system on classic editor?.

    I have 8.147 Tags on my WordPress.

  9. ActionCoding commented on Feb 12, 2019

    @ActionCoding

    I am also having the same issue when entering tags. Sometimes it is using so much memory it slows my system to a hault. Is there any way to use the old system for tags where it saves them when you click to update the post instead of when you are typing them in?

  10. MartinHlavna commented on Mar 30, 2019

    @MartinHlavna

    Same issue here, on smaller scale.

    Loadnig of 50 categories takes about 3-4 seconds, which is kinda usable.
    Hower typing tags (3023 at the time of writing) is real problem. If I type multipe tags at once they dissappear. Selecting tag from search results kinda helps, but loading takes more than 10 seconds.

  11. SuzuKube commented on Apr 2, 2019

    @SuzuKube

    Same problem :/ ! On the tags ^^'

  12. designsimply commented on Apr 16, 2019

    @designsimply
    Member

    I think it helps for new people commenting to mention the total number of tags they have on their site. Thank you to those who have commented so far.

  13. psokolovs commented on Apr 28, 2019

    @psokolovs

    I have a few thousand tags, and this is a serious issue for me. Especially because my server is pretty slow, so each API call is about a 1 second response time. It's basically paginating non-stop.

  14. oxyc commented on Apr 30, 2019

    @oxyc
    Member

    A quick hack I use for a taxonomy called postal_code so it returns up to 100000 terms per request:

    add_filter('rest_postal_code_query', function ($prepared_args, $request) {
      if (strpos($request->get_route(), '/wp/v2/') === 0) {
        if ($prepared_args['number'] === 100) {
          $prepared_args['number'] = 100000;
        }
      }
      return $prepared_args;
    }, 10, 2);

    source: https://github.com/WordPress/gutenberg/pull/10762/files#diff-d0c65e7ac505d44d8571ddaffc510d98L412

  15. 36 remaining items

  16. jhmonroe commented on Jul 31, 2024

    @jhmonroe

    Seconding all of this and confirming that if I deactivate Rest API for certain post types, the Category/Tag AREAS load instantly in Classic editor. Have noticed similar issues where Featured Image, Category, and Tag areas all loads last in the WP Admin sidebar. Often 10-20 secs after the rest of the admin, content of the post, etc is all loaded. It seems to be something with Rest API and the order in which the admin loads.

    In the video I posted here, you can see Categories and Tags loading way after (and also note that before they load, they do not show up as an option in Preferences
    #55460 (comment) (< video is comment on this post)

    The site overall has 18 categories and 28 tags for normal posts. Even in a CPT with 3 categories, this slow loading occurs. So really not the numbers that are the source of some of the delays mentioned above.

    In the attached screenshot, you can see it's one of the last things to load on the page and takes many MS.
    Screen Shot 2024-07-30 at 10 55 10 PM

    Although this is a "backend" issue, it really is front-facing in the sense that our clients see this. Ultimately it affects the entire ecosystem of designers, developers, etc who evangelize custom Wordpress sites to clients as a great product overall but a bug like this makes the client think Wordpress is hard to use when things don't appear sometimes or take a long time to appear.

  17. swissspidy commented on Jul 31, 2024

    @swissspidy
    Member

    The REST API requests themselves are quite fast on my local site. If they are slow for you, I'd suggest looking into profiling those requests with XHProf.

    From what I read in this issue and see in my own testing, the main problem is that the editor only renders the categories panel after paginating through all the categories, which is slow if you have hundreds of those. And there's not even a spinner or anything. #29393 would solve this (and yes, maybe it can be solved as part of #61852). So I'd recommend focusing on that part first and foremost.

    Thanks for flagging this issue. Currently, the Core Performance team is primarily focused on performance issues that affect end users of the site and not as much performance issues that are encountered in the admin. Even so, it's possible that this demonstrates a potential issue affecting core APIs that needs to be fixed.

    FWIW I second this. The Gutenberg team is fare more experienced with the editor architecture and React performance best practices. It doesn't make sense for the core performance team to "take over", but of course we can help where possible.

  18. moved this to Not Started/Backlog 📆 in WP Performance Ongoingon Aug 9, 2024
  19. Mamaduka commented on Aug 27, 2025

    @Mamaduka
    Member

    I think the remaining issue here is with hierarchical taxonomies, such as categories, where the editor must make unbound requests (perPage: -1) and wait until all responses are returned before rendering any content. This was confirmed in recent tests by @supernovia.

    Considering some recent improvements to the data layer, I think I've some ideas how to fix this. A good start would be to display intermediate results, along with a loading indicator in the right places, to communicate that data fetching hasn't finished yet.

    I'm going to assign the issue to myself and will try to PR for the proposed solution.

  20. self-assigned this
    on Aug 27, 2025
  21. jhmonroe commented on Aug 27, 2025

    @jhmonroe

    @Mamaduka visual feedback for the user experience and intermediate results would really help! Very good idea.

    Curious how you think "intermediate results" might be handled.

    One approach might be that if a site only has, say, 10–12 or less categories, it simply outputs them as checkboxes (like Classic).
    If there are more than 10, it proceeds with the new method. I guess these are what we might call Conditionals?

    Jetpack's slideshow has conditionals this way... when there are less than X images, it displays dot indicators for the # of slides. If there are more than X, it shows "X of XX"

    These types of approaches sort of follow what's called PROGRESSIVE DISCLOSURE, where the user experience is improved by only showing users what they need at any given moment. And not showing too much or having a complicated solution when it's not warranted.

  22. Mamaduka commented on Aug 28, 2025

    @Mamaduka
    Member

    Curious how you think "intermediate results" might be handled.

    It will try to build the "tree" with the first 100 results and display a loading indicator. Unfortunately, the current design/structure requires fetching all categories to build the UI, so we're limited in how much "progressive disclosure" or "virtualizing" techniques can be applied.

  23. added
    [Status] In Progress
    on Aug 29, 2025
  24. dmsnell commented on Aug 31, 2025

    @dmsnell
    Member

    @Mamaduka we did some related work in Calypso for building comment management, where some sites and even some posts had thousands of comments in a big tree, and the tree was not chronological either (some very old comments would get very new responses).

    we built a new API to power this which provided a trimmed-down tree of the hierarchical comments which is then used to quickly render the UI structure while the UI lazy-loads the content. this is how we were able to get the pagination working without loading all of the comment data, and then have the first page loaded fast and first.

    you can see it at the Developer Console for wordpress.com. You can enter /sites/mysite.mydomain/comments-tree to see it for any site you may have there.

    Image

    in some experimentation I found more-optimized ways of sending this rather than as a JSON data structure which cut the size down substantially, and grabbing all of the data from the database was optimized as well.

    if you think this is of use here I’d be happy to expand on it. it doesn’t look like the general-purpose API endpoints but it was built to power a UI panel that could not wait until 10,000 comments loaded from the normal one. in fact though, this is how we build effective, simple, and performant APIs rather than re-exporting the database through generic CRUD interfaces, but that’s a story for another time.

  25. Mamaduka commented on Sep 2, 2025

    @Mamaduka
    Member

    @dmsnell, thanks for sharing a great example. I think we will eventually need similar sub-endpoints to represent hierarchical data in various places, such as Panels and DataViews. IIRC, @oandregal worked on something related for the post types, though it also had some performance implications. Ref: #66479 (comment).

    My current solution is somewhat naive and uses a recent experimental feature to render results as they're received from the server - #71402.

  26. dmsnell commented on Sep 3, 2025

    @dmsnell
    Member

    I couldn’t tell from the linked comment what was causing the performance issues, whether it was the API fetch or the UI rendering.

    One note about what we built with the comments-tree — we abandoned WP_Query(). Now I don’t know if that’s relevant here because when we built that I wasn’t aware that we could add 'fields' => 'id=>parent`` and get the parent and child ids. Still, it’s an avenue to consider because I vaguely remember hitting performance-relevant issues with WP_Query` vs. a raw SQL query.

    [RECEIVE_INTERMEDIATE_RESULTS]

    Hm. Nice. That was an inevitable need given the way the data fetching assumes requests start and end and give no introspection to that process.

    Another thing I experimented with was sending HTTP chunked data, or of simpler mechanisms to flush the output buffer while building a request.

    The thing with the comments-tree was that it was fast enough and small enough to send in its entirety to the browser, which let the UI instantly render as it wanted, even with blanked-out data (spinners or skeletons instead of tag names, etc…). Then normal fetching and caching kicked in and the data appeared progressively by nature, not by code.

    While it appears like RECEIVE_INTERMEDIATE_RESULTS might work on pagination, if we use chunked encoding or buffer-flushing we actually want to use JS’s progressEvent to track the download. This also requires using something like a partial JSON parser, or LD+JSON. But, it’s a simple method to start getting content from the server to the UI much much faster.

  27. Mamaduka commented on Sep 3, 2025

    @Mamaduka
    Member

    Hm. Nice. That was an inevitable need given the way the data fetching assumes requests start and end and give no introspection to that process.

    Right, there's not a lot you can derive from core data resolution statuses, but it works for most of our current cases.

    You can also use currentItems and totalExpectedItems state with RECEIVE_INTERMEDIATE_RESULTS flag to display more interactive loading states. I tried that initially, but it was decided to use the spinner instead.

    Another thing I experimented with was sending HTTP chunked data, or using simpler mechanisms to flush the output buffer while building a request.

    I've used server-sent events in the past for some client project, and it was a project I really enjoyed.

    Shipping similar specialized endpoints seems to go against WP philosophy, but it would be great to see how far we can push the limits with existing or new general APIs. Which you're already doing with HTML API 🦸

    P.S. If you have any resources for optimizing/rendering large data trees on the client, please share 😄

    Screenshot

    CleanShot.2025-09-03.at.17.55.34.mp4
  28. dmsnell commented on Sep 3, 2025

    @dmsnell
    Member

    Shipping similar specialized endpoints seems to go against WP philosophy, but it would be great to see how far we can push the limits with existing or new general APIs. Which you're already doing with HTML API

    The neat trick with flushing the output buffer is that it’s 100% compliant with existing pause-the-world-until-it’s-done solutions. The only difference is that the client uses line-buffering on the progress event to partially decode the JSON.

    While not deployed (for other reasons), this is something I worked into the bell notifications on WordPress.com. It required only a little finagling on the client side, and while line-delimited JSON would have helped, it was not necessary.

    If you have any resources for optimizing/rendering large data trees on the client, please share

    That was my intent linking to the comments-tree. It was the reliance on React to lazy-load the actual content which led to implicit optimization, because no data was pulled which wasn’t necessary.

    The initial load of the structural information (the ids with their hierarchy) was small enough to get the UI skeleton rendered, and with a single page, this wasn’t much at all. Then, whichever categories are visible can declaratively load the actual category information like slug, title, etc… Would leave it to a small abstraction to batch those requests into “paged” requests (for example, with a debounce of 50ms, gather all requested IDs and transform it into a single API call).


    As for the fact that we have a tree/list of 10,000 items that’s more in the domain of things like the older Virtualized List components. Still, if we have the structural hierarchy, have you considered a filterable list like a datalist component would provide? For any matching tags we can show that lineage of the tree both up and down. Strike some balance between showing too many categories through which to scroll and find the right one and showing no context when you find one.

  29. moved this from Not Started/Backlog 📆 to Done 😃 in WP Performance Ongoingon Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Feature] Document Settings[Status] In Progress[Type] Performance

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions