Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
category_node_get_categories_by_container() can be called several times per page load. On a current site, we get 150+ calls to this function on the Update/Insert of nodes.
Each time this function is called, it makes a separate, identical request the database. This patch adds static caching to the database query so duplicate queries are not executed.
Comment | File | Size | Author |
---|---|---|---|
#1 | categories_by_container_cache5.patch | 1.54 KB | quicksketch |
categories_by_container_cache.patch | 1.56 KB | quicksketch |
Comments
Comment #1
quicksketchSame patch for 5.0
Comment #2
JirkaRybka CreditAttribution: JirkaRybka commentedThe 5.x version is not supported anymore (unless someone volunteers), as stated by the maintainer.
In the 6.x-2.0-rc1 release, there's a different caching mechanism, that already adds both static AND database caching to ALL the expensive API functions (including the one mentioned here). See #501378: PERFORMANCE! Central caching for category API functions for details on that.