Unnecessary multiple requests with the same esagg query #182919
Labels
Feature:Search
Querying infrastructure in Kibana
Team:Visualizations
Visualization editors, elastic-charts and infrastructure
Unnecessary multiple requests with the same esagg query
When a search is sent to ES and a response is received, the search service is looking if the request needs a post-flight request.
kibana/src/plugins/data/common/search/search_source/search_source.ts
Lines 539 to 548 in 74fdd1b
If needed, it transforms the response to a
partial
response and update the body with the postflight request.This works correctly if the postflight is actually necessary, but due to the current implementation the postflight request is always "applied" even if not needed, causing a subsequent request to be sent to ES.
This results to an increase of:
Analysis
The current method that checks if a request needs a subsequent post-flight request relies on a loose check from the function
hasPostFlightRequests
. This function checks if the agg propertytype.postFlightRequest
is a function.kibana/src/plugins/data/common/search/search_source/search_source.ts
Lines 474 to 483 in 74fdd1b
This function is there even if is not required. For example in a
terms
aggregation without theother
bucket the function is still there but just return its identitykibana/src/plugins/data/common/search/aggs/buckets/terms.ts
Line 93 in 74fdd1b
All the other cases this is defaulted to an
identity
function, so thehasPostFlightRequests
function will always return true.kibana/src/plugins/data/common/search/aggs/agg_type.ts
Line 311 in 74fdd1b
The text was updated successfully, but these errors were encountered: