custom_breadcrumbs_load_breadcrumbs() and custom_breadcrumbs_set_menu_breadcrumb() functions generate huge amount of identical databse queries.

Devel module shows me next queries when I load my site taxonomy/term/5 page:

duration  count  function                                 query
--------------------------------------------------------------------------------------
.......
0.09        9    custom_breadcrumbs_set_menu_breadcrumb   SELECT mlid FROM menu_links WHERE link_path = 'taxonomy/term/5'0.1278custom_breadcrumbs_load_breadcrumbsSELECT * FROM realty_custom_breadcrumbs_paths WHERE specific_path = 'taxonomy/term/5' AND language IN ('ru','') ORDER BY language ASC
0.14       78    custom_breadcrumbs_load_breadcrumbs      SELECT * FROM custom_breadcrumbs_paths WHERE specific_path = 'taxonomy/term/5' AND language IN ('ru','') ORDER BY language ASC
0.13       78    custom_breadcrumbs_load_breadcrumbs      SELECT * FROM custom_breadcrumbs_paths WHERE specific_path = 'taxonomy/term/5' AND language IN ('ru','') ORDER BY language ASC
0.21        9    custom_breadcrumbs_set_menu_breadcrumb   SELECT mlid FROM menu_links WHERE link_path = 'taxonomy/term/5'
0.11       78    custom_breadcrumbs_load_breadcrumbs      SELECT * FROM custom_breadcrumbs_paths WHERE specific_path = 'taxonomy/term/5' AND language IN ('ru','') ORDER BY language ASC
0.09        9    custom_breadcrumbs_set_menu_breadcrumb   SELECT mlid FROM menu_links WHERE link_path = 'taxonomy/term/5'
0.11       78    custom_breadcrumbs_load_breadcrumbs      SELECT * FROM custom_breadcrumbs_paths WHERE specific_path = 'taxonomy/term/5' AND language IN ('ru','') ORDER BY language ASC
.......

This is only small excerpt from log. There are much more identical queries generated by custom_breadcrumbs_load_breadcrumbs() and custom_breadcrumbs_set_menu_breadcrumb() functions to load the page.
I believe it is very expensive to make hundreds database queries in order to show just breadcrumbs.

Suggested patch makes use of static variables to cache identical queries in mentioned functions.

CommentFileSizeAuthor
#1 custom_breadcrumbs-cache.patch2.83 KBv.sidorov
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

v.sidorov’s picture

Here is the patch.

MGN’s picture

Version: 6.x-2.0-beta3 » 6.x-2.x-dev
Category: task » feature
Status: Active » Needs review

Thanks. This is an excellent idea. I'll test it out and get it into 6.x-2.x-dev and the upcoming beta4 release.

MGN’s picture

Status: Needs review » Fixed

Committed to 6.x-2.x-dev. http://drupal.org/cvs?commit=372384

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.