app/vmselect/promql: clarify comments on why the right side of if and and operators are executed at first

This commit is contained in:
Aliaksandr Valialkin 2022-02-03 00:26:14 +02:00
parent 4b850c2a59
commit 96b7de6736
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -285,10 +285,10 @@ func evalExpr(ec *EvalConfig, e metricsql.Expr) ([]*timeseries, error) {
var tssLeft, tssRight []*timeseries var tssLeft, tssRight []*timeseries
switch strings.ToLower(be.Op) { switch strings.ToLower(be.Op) {
case "and", "if": case "and", "if":
// Fetch right-side series at first, since the left side of `and` and `if` operator // Fetch right-side series at first, since it usually contains
// usually contains lower number of time series. This should produce more specific label filters // lower number of time series for `and` and `if` operator.
// for the left side of the query. This, in turn, should reduce the time to select series // This should produce more specific label filters for the left side of the query.
// for the left side of the query. // This, in turn, should reduce the time to select series for the left side of the query.
tssRight, tssLeft, err = execBinaryOpArgs(ec, be.Right, be.Left, be) tssRight, tssLeft, err = execBinaryOpArgs(ec, be.Right, be.Left, be)
default: default:
tssLeft, tssRight, err = execBinaryOpArgs(ec, be.Left, be.Right, be) tssLeft, tssRight, err = execBinaryOpArgs(ec, be.Left, be.Right, be)