Cache results in _drupalorg_testing_get_tid_by_term()

dww - October 12, 2008 - 05:24
Project:Drupal.org Testing
Version:5.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:aclight
Status:closed
Description

I noticed this while reviewing the latest patch for #231640: Auto-generate some release nodes:

Neither _drupalorg_testing_get_tid_by_term() nor taxonomy_get_term_by_name() cache their results.

_drupalorg_testing_get_tid_by_term() is called in a nested foreach loop when generating release nodes, and therefore, we're doing A LOT of duplicate queries.

Yes, it's an install profile, so we don't really care about performance that much, but we don't need to ruthlessly pound the DB for nothing. ;) Think of the kittens on shared hosting test sites that might get in trouble with bogus queries/second quotas and the like...

#1

aclight - October 12, 2008 - 16:15
Assigned to:Anonymous» aclight
Status:active» patch (code needs review)

Ok, here we go. By my count, this saves 318 db queries over multiple seconds. Probably not that big of a deal, but maybe in the future when this profile has 1000 projects in it the savings will become significant. :)

AttachmentSize
320150_dot_cache_tids.patch1.24 KB

#2

dww - October 12, 2008 - 18:47
Status:patch (code needs review)» patch (reviewed & tested by the community)

Perfect, thanks.

#3

aclight - October 12, 2008 - 20:27
Status:patch (reviewed & tested by the community)» fixed

Committed to HEAD
http://drupal.org/cvs?commit=145978

#4

Anonymous (not verified) - October 26, 2008 - 20:32
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.