mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-07-23 17:21:27 +03:00
This commit improves performance for sub query requests by properly cache binary operation results. For context: When using binary operator in query, vmselect will executes the left and right expressions in parallel and independently. When the left and right expressions contain the same sub-expression, e.g. ``` count( count(vm_requests_total) by (action,addr,cluster,endpoint) ) by (action,addr,cluster) / count( count(vm_requests_total) by (action,addr,cluster,endpoint) ) ``` ```count( count(vm_requests_total) by (action,addr,cluster,endpoint) is a sub expression in both left and right side.``` The sub expression will be executed twice (once in each of the left and right expressions). This introduces additional RPC and resource overhead. Currently, this feature is hidden behind query request param - `optimize_repeated_binary_op_subexprs`. Later it could be transited into default behavior. Fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10575