-
Notifications
You must be signed in to change notification settings - Fork 3
Description
When refreshing promotions for a customer, what I’d like to do is:
-
Get IDs of all groups the customer belongs to:
-
from Postgres — trivial
-
from ES — less so; we can use a multi-search to get rid of round-trips, but there’s no way to short-circuit a query, when its first result is found, confirmed by Mark Walkom from ES:
07:02 <michalrus> Hey, I have N queries, and would like to know about each if it has 0 or non-0 results. Can this be done in 1 request? I guess I could use
_msearch. But is there anything more performant than checking length of results for a given search and later comparing it with 0? If ES finds at least one result, it could short-circuit in my case.08:37 <@warkolm> michalrus: there's no other way
-
-
Only then use those IDs when checking promotion applicability.
This is still inefficient, but at least not as inefficient as the current code. When we decide to go with caching one day, this code should be useful then, too. :)
/cc @Anna-ZZZ