Performance Question
Hi Low,
We have a pretty heavy section on our website that makes heavy use of the low_search_results tag. I wonder I you might have an idea on how to keep performance as optimal as possible. The layout we need is really specific and complicated. It requires us to make use of multiple low search tags that seems to give some performance issues.
Let me explain the situation a bit.
We have a website that shows content from all channels based on three filters:
1: Sport category
2: Age category
3: Location / City
1 - 2: Just categories.
3: Lat / Lng values.
Right now we have ten channels and we need results from all of these channels, but for every channel we need a seperate low_search results loop. This seems to be very heavy. The amout of queries is about 200, but they execute very fast, say within 0.1 second. But the overall execution time is 1.3 / 2.0 seconds on our testing server.
In many cases I don't absolutely need the low search results tag, and a regular channels entries loop might also work. The only issue is I have integrated some special features using some hooks of your module. For example to give location based results.
Do you think it matters if I would switch to using the regular channel entries loop and only use low search when it's absolutely neccessarry? Do you have some other insights regarding performance of such page?
This is the stash partial in question: http://pastebin.com/YdFBeGm3
This is more of an advice question. I'm well aware that using ten loops in a single template has performance implications. Just looking through my options without completely falling back on perfomance gains just by caching my results.
If you need login credentials to our project I can give them to you.
Replies
Low 12 Dec 2013 13:22
I see you've extended Low Search to "webs_low_search". How this affects performance, I cannot tell you. I'd recommend you extend Low Search with custom search parameters using the available hooks or writing your own filters which you can simply drop in the /filters/ folder (although there are no docs about that approach).
Multiple tags will always affect performance in a bad way. Whether you're using the LS tag or native channel:entries, that doesn't really matter. You could try and use a single tag for all channels and differentiate between them inside the tag itself.
Other things I can see: you're defining a collection, but you're not using the keywords filter. Collections are actually only effectively used when searching using keywords. If you're not, you can omit it and just use the channel="" parameter instead.
Edit: Also, I'm no Stash expert, so I don't know how much that will improve performance or not.
Dion Snoeijen 12 Dec 2013 13:46
Hi Lodewijk,
Thanks for your quick response. Actually I have two extensions for low search that I use to extend its functionality. One to add functionality that lets me return entries that have children within a certain category, and one that enables a location based query. But it's not so much the queries that seem to cause it to become relatively slow.
The reason for extending low search is to set get parameters so I can have my parameters in url segments.
For example this is a url: kngu.webslab.nl/sport-acrogym/leeftijd-5-10/woonplaats-eindhoven
acrogym and 5-10 translate to two category id's and are set to $_GET['category'] eindhoven is set to lat / lng values and set to a custom param used by my extension. I'm not sure, but I don't think this will be performance heavy.
Using one loop is something I have tried before but didn't really make a difference. This was much earlier on in the project so I will try again to see if it's helping.
Thanks for your info. I will be trying some more things now.
Low 12 Dec 2013 14:00
Well, try and look at query times, but also processing times in the Template Debugger. The toolbar ( http://dvt.ee/eedebug ) might also help to discover where possible bottlenecks lie.
I would recommend having a single tag rather than multiple. This will definitely cut down queries, so *should* bring down load times as well. However, the way you're using Stash kind of obfuscates things for me a bit.
Dion Snoeijen 12 Dec 2013 19:04
Yes, I imagine :D. I think you are referring to the bottom lists. We have some very specific template needs for this project, not something I would want to bore you with. Right now I have brought it down to one tag. But in fact it doesn't cut the queries down much, if even at all. I was at 220, now I'm at 180. But it's 180 without having all features back in place. But like I said, I don't think it's the queries, and with your help now I understand I think I'm looking for the cause in the wrong place.
I think it's because I'm looping through my results and for every result I embed a partial. That will be my quest to find out!
Thank you very much for your time and insights!
Dion Snoeijen 12 Dec 2013 19:23
One more small question: Does the disable param actually do something for the low search tag?
Low 13 Dec 2013 08:07
The disable param is the same as the one on the channel:entries tag.