2

I'm curious if anyone that has either done a comparison between the two or simply knows why one would be more efficient than the other. Stash set vs. set_list in storing multiple individual field variables for a single entry.

Example:

A template group index that generates "pages" on the basis of entries that includes, for example, the following fields:

  • title (obviously)
  • alt menu title
  • body (RTE field)
  • promo image
  • extended body (RTE field)
  • Meta Title
  • Meta Description
  • Meta Keywords

So to create a variable out of each one of these fields distinctly, I could either wrap each with a simple stash:set tag pair or I could wrap the whole thing with a stash:set_list tag pair and wrap each variable with the tag pair to set each as list elements.

Then in the wrapper template, in the set_list scenario, when I have several of these elements that actually need to appear together (like title, body, extended body and promo image, for example), I can use a single get_list tag pair to retrieve the several of them I need whereas with the simple set scenario, I would need a get for each variable separately, even if four of them follow one another sequentially in the markup.

What are the performance issues I should be worries about? Or should I be worries about it? To me, they seem to run about the same speed, but I wonder if the database and stash experts out there can speak to how/if there would be differences, particularly as the number of fields in a given field group climbs.

I have thought about the fact that the stashed body of the page could in fact combine several of the fields in the field group into a single stashed set (whether list or not). But for the purposes of this example/question, I thought I'd keep them separate.

5

A stash list is simply a serialized variable. Setting and getting a list is the same process as setting/getting a single variable, except the list has some additional processing to separate out the elements, serialize/unserialize, sort and paginate. In practice if you are not saving the variables with save="yes" then there is little appreciable difference in speed or memory use. However, if you are saving your variables then a list is more efficient than multiple individual variables because it requires only a single query to retrieve, regardless of how many times the list is iterated over in your template.

Another option for saving multiple variables as a single cached item (especially where individual parameters are required per variable, e.g. match / against) is the {exp:stash:bundle} tag pair.

| improve this answer | |
  • Cool! Thanks so much Mark. Exactly the kind of information I was looking for - and who would know better than you!?! – Jean St-Amand Feb 6 '13 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.