<p>I have a site where I need to paginate and filter a list of businesses by different criteria. In the business entry, I’m using the Reasons plugin tied to about 8 different lightswitches which, when activated, reveal different inputs that can be modified. For example, if it’s a restaurant, turning that lightswitch on reveals a toggle for if it’s local, and a channel of different types of restaurants to choose from. That business might also be a venue to host events, so activate Venue and you get a table input to add information about the rooms.</p>

<p>To view and sort all restaurants, In my template, I was pulling all businesses, looping through and if it’s a restaurant, create the list item. Filtering and pagination were then being handled by list.js. This allowed me to have two dropdowns — one for neighborhood and one for restaurant type. Simply select “Thai” and "Downtown" and the list updated instantly.</p>

<p>It all worked great when there were just a few items in the list. Now there are close to 500 businesses total and about 250 that are classified as restaurants. When I pull then entries, if there are north of 150 results that need to be listed, the page just becomes unresponsive.</p>

<p>I changed the way I was pulling the entries from pulling businesses and then filtering, to sending search criteria in the request, but that didn’t seem to help. The bottleneck seems to be in processing the list data and creating the list items to be paginated and searched. If I just list out the entry.title, it takes a bit but it works. If I  add the filtering data attributes, phone, address, etc to the list items, it chokes.</p>

<p>Is there is a way to have live sorting on a page with a large dataset? I’d like to avoid page refreshes if possible. Perhaps pull json data, sort, and then just display the items that need to be rendered on the screen? I’m having trouble finding examples for alternate filtering methods for Craft.</p>

<p>Thanks.</p>

CC BY-SA 3.0
2015-09-22T19:32:59.083Z
I'm not sure I'm following where the bottleneck is occurring... on the client/Javascript side or on the PHP/Twig side? If you enable devMode, then look at the profiling output in your browser's console it will reveal some performance info.
Brad Bell
CC BY-SA 3.0
2015-09-23T13:33:49.677Z
I believe it's on the php/twig side. There's a bit of a lag when I pull the list but it's not a show stopper. If I just output the titles, it's ok, but if I output the address, contact information and add data attributes for list.js to use for sorting, I run into memory limit errors and execution time errors after bumping the memory up.
idahotallpaul
<filter><performance><sorting>
Performance problems filtering lists
# Performance problems filtering lists

(Asked by: username_0 on 2015-09-22)

I have a site where I need to paginate and filter a list of businesses by different criteria. In the business entry, I’m using the Reasons plugin tied to about 8 different lightswitches which, when activated, reveal different inputs that can be modified. For example, if it’s a restaurant, turning that lightswitch on reveals a toggle for if it’s local, and a channel of different types of restaurants to choose from. That business might also be a venue to host events, so activate Venue and you get a table input to add information about the rooms.

To view and sort all restaurants, In my template, I was pulling all businesses, looping through and if it’s a restaurant, create the list item. Filtering and pagination were then being handled by list.js. This allowed me to have two dropdowns — one for neighborhood and one for restaurant type. Simply select “Thai” and "Downtown" and the list updated instantly.

It all worked great when there were just a few items in the list. Now there are close to 500 businesses total and about 250 that are classified as restaurants. When I pull then entries, if there are north of 150 results that need to be listed, the page just becomes unresponsive.

I changed the way I was pulling the entries from pulling businesses and then filtering, to sending search criteria in the request, but that didn’t seem to help. The bottleneck seems to be in processing the list data and creating the list items to be paginated and searched. If I just list out the entry.title, it takes a bit but it works. If I add the filtering data attributes, phone, address, etc to the list items, it chokes.

Is there is a way to have live sorting on a page with a large dataset? I’d like to avoid page refreshes if possible. Perhaps pull json data, sort, and then just display the items that need to be rendered on the screen? I’m having trouble finding examples for alternate filtering methods for Craft.

Thanks.

**Tags:** filter, performance, sorting

> **Comments:**
> **username_1**: I'm not sure I'm following where the bottleneck is occurring... on the client/Javascript side or on the PHP/Twig side? If you enable devMode, then look at the profiling output in your browser's console it will reveal some performance info.  
> **username_0**: I believe it's on the php/twig side. There's a bit of a lag when I pull the list but it's not a show stopper. If I just output the titles, it's ok, but if I output the address, contact information and add data attributes for list.js to use for sorting, I run into memory limit errors and execution time errors after bumping the memory up.  

---

## 0 answers

