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

plan queries in random order during warm up #3769

Closed
Tracked by #3704
Geal opened this issue Sep 6, 2023 · 0 comments · Fixed by #3800
Closed
Tracked by #3704

plan queries in random order during warm up #3769

Geal opened this issue Sep 6, 2023 · 0 comments · Fixed by #3800
Assignees

Comments

@Geal
Copy link
Contributor

Geal commented Sep 6, 2023

Right now, queries are extracted from the cache and ordered according to their frequency by the in memory cache. That means all the router instances will warm up the same query roughly at the same time. If they are using distributed caching, they are racing to do the same work and cannot share much.

If we reorder the queries randomly (after selecting the most used), then there's a higher chance that each router would plan a different query, stores the plan in Redis, and as warm up progress, they will get more plans directly from Redis instead of recalculating them

Geal added a commit that referenced this issue Sep 18, 2023
Fix #3769 

When using query plan cache warm up, we take the list of most used
queries from the in memory cache, and plan them. The list will come in
order, from the most used to the least used.
If multiple router instances are using cache warm up, and are also
configured to use the distributed cache for query plans, then they would
all plan the list of queries in the same order, since they will have
roughly the same distribution in the in memory cache. By randomizing the
list of queries, we increase the chances that other instances can get
plans from the distributed cache during warm up instead of calculating
them, because other instances might have already done the work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant