Answer the question
In order to leave comments, you need to log in
Recalculation of goods at store filter attributes?
I store attributes and values in the Postgres jsonb field in the products table. When selecting an attribute value checkbox, you need to recalculate the number of products for all other filter values in order to make those checkboxes with 0 products inactive.
This is implemented in most stores, or Yandex Market, as an example.
The question is, how best to recalculate these values?
You can iterate over each attribute value and make a query.
But if the filter is large, then there will be a large number of requests.
Maybe there is a better option? For example, take all products into an array (only jsonb data fields), filter it and count the number of elements?
But if there are 40 filter attributes, then you need to filter and read the original array 40 times. Whether it will be faster, than to consider in sql I do not know.
How would you decide this?
Answer the question
In order to leave comments, you need to log in
How are complex filters arranged in online stores?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question