-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Skip can match when batched query execution is available #127471
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
base: main
Are you sure you want to change the base?
Skip can match when batched query execution is available #127471
Conversation
No need to do the can_match phase for those nodes that support the batched query phase. We can get the equivalent degree of pre-filtering by simply running can_match for sort based queries.
There's no reason whatsoever to run can_match (except the coordinator rewrite part of it) when batched query execution is used. On a per-node level we can still run it to order the shrds but shoul probably remove its use from the query phase completely if there's no sort in the query.
…skip-can-match-on-batched
@@ -562,15 +643,39 @@ static void registerNodeSearchAction( | |||
final int searchPoolMax = threadPool.info(ThreadPool.Names.SEARCH).getMax(); | |||
transportService.registerRequestHandler( | |||
NODE_SEARCH_ACTION_NAME, | |||
EsExecutors.DIRECT_EXECUTOR_SERVICE, | |||
threadPool.executor(ThreadPool.Names.SEARCH_COORDINATION), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we do can_match here as well we absolutely must fork this to search_coordination, at least for the time being.
shardSearchRequests[i] = r; | ||
var canMatch = searchService.canMatch(r); | ||
if (canMatch.canMatch()) { | ||
r.setRunCanMatchInQueryPhase(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit hacky for now and we should clean this logic up further, but somewhat of a nice speedup to save one round of creating a searcher and whatnot and a win we should take right away IMO.
final var shardId = shardToQuery.shardId; | ||
ShardSearchRequest r = state.shardSearchRequests == null ? null : state.shardSearchRequests[translatedIndex]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit messy too for the time being, but kind of neat to save building the requst again as a win in this step, we can refine this further to make it look nicer and maybe also dedup some of the lucene internal query object building down the line.
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
Admittedly a little dirty, but intentionally kept close to the exitsting logic, we can clean up and optimize in follow-ups, in any case this is a considerable speedup in essentially all possible use cases (we always save a network roundtrip inlcuding serialization and everything).
There's no reason whatsoever to run can_match (except the coordinator rewrite part of it)
when batched query execution is used.
On a per-node level we can still run it to order the shrds but shoul probably remove its
use from the query phase completely if there's no sort in the query.
relates #125788