JacksonRiver/springboard_modules — pull request #5 by benclark (2012-01-12 17:22:47+00:00)
Title: Reduce the number of database hits coming from fundraiser_walk_component_hierarchy

From my original email re: this patch, which has already been applied to IFAW and has been stable there:

--

I did a devel db query list and saw that the SELECT cid, pid, form_key FROM {webform_component} WHERE nid = %d query was being run multiple times per nid and cid, often for duplicate content (which devel flagged in red).

My first fix was to store the result per nid and cid, but it was still running a separate query for all webform_components on the form. There weren't any duplicate queries, but it was still 30 queries for 30 components. I decided it would save even more time if I just grab all the components on the requested node at one time, then statically cache them in an array. Now it only runs once.

I also considered doing a node_load() for the $nid, which in almost all cases would already be cached and would require no extra database hits. But I would then have to transform $node->webform['components'] into the expected format, and I thought I was already making huge improvements with the changes you see in this patch file, so I didn't pursue that.