Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize promos a bit #2297

Open
michalrus opened this issue Jun 26, 2017 · 0 comments
Open

Optimize promos a bit #2297

michalrus opened this issue Jun 26, 2017 · 0 comments

Comments

@michalrus
Copy link
Contributor

michalrus commented Jun 26, 2017

When refreshing promotions for a customer, what I’d like to do is:

  1. Get IDs of all groups the customer belongs to:

    1. from Postgres — trivial

    2. 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

  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant