Body: <p>I currently have about 420 products and over 100 of categories to choose from for each products, showing the list of categories and filtering it, works fine, and performance is not too bad when it's also cached.</p>
  
  <p>What I'm trying to do now is show the total number of products for each filter, but it has to update when I select a filter,(on a side note: my filter is currently being done through ajax).</p>
  
  <p>My issue is that, with all the number of products and filters, when I get all the total number products for that filter, it gets very query heavy and slow which is not a good user experience.</p>
  
  <p>What's the best way to do this, performance wise?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T08:57:48.637Z
Comments.Text: Do you want to update the number of matching products based on your latest query or based on all products. So for an example the user enters your shop and has 100 products for filter A and 50 products for filter B when the user selects filter A the number of products for filter B should be updated?
Comments.UserDisplayName: Robin Schambach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T12:32:46.640Z
Comments.Text: I want to update the number of products based on the latest query.
Comments.UserDisplayName: pinksorceress23
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-20T12:47:14.720Z
Comments.Text: With 400+ entries and so many different filters I would suggest you to build your search with angular. This is a javascript framework and it seems your desire perfectly fits to this since it replaces the calculations from the server to the client and thus increases the speed and it makes everything easier for you. I faced the same problem some time ago and was able to make my request 400% faster because I didn't need to render the templates anymore and I build my own database query instead of using the one from the elementCriteriaModel. Unfortunately I don't have another suggestion
Comments.UserDisplayName: Robin Schambach
Tags: <plugin-craftcommerce><categories><relations><performance>
Title: Filtering products by categories and showing number of products related to selected category
ThreadText: # Filtering products by categories and showing number of products related to selected category
  
  (Asked by: username_0 on 2017-10-19)
  
  I currently have about 420 products and over 100 of categories to choose from for each products, showing the list of categories and filtering it, works fine, and performance is not too bad when it's also cached.
  
  What I'm trying to do now is show the total number of products for each filter, but it has to update when I select a filter,(on a side note: my filter is currently being done through ajax).
  
  My issue is that, with all the number of products and filters, when I get all the total number products for that filter, it gets very query heavy and slow which is not a good user experience.
  
  What's the best way to do this, performance wise?
  
  **Tags:** plugin-craftcommerce, categories, relations, performance
  
  > **Comments:**
  > **username_1**: Do you want to update the number of matching products based on your latest query or based on all products. So for an example the user enters your shop and has 100 products for filter A and 50 products for filter B when the user selects filter A the number of products for filter B should be updated?  
  > **username_0**: I want to update the number of products based on the latest query.  
  > **username_1**: With 400+ entries and so many different filters I would suggest you to build your search with angular. This is a javascript framework and it seems your desire perfectly fits to this since it replaces the calculations from the server to the client and thus increases the speed and it makes everything easier for you. I faced the same problem some time ago and was able to make my request 400% faster because I didn't need to render the templates anymore and I build my own database query instead of using the one from the elementCriteriaModel. Unfortunately I don't have another suggestion  
  
  ---
  
  ## 0 answers
  
  