FLUX Optimisation: Pushdowns

Hey Community,

performance wise, are Query 1 and Query 2 the same or not? ie 1 filter statement vs 3 filter statements, does it make a difference?

Query 1:
from(bucket: “TESTBUCKET”)
|> range(start: 0)
|> filter(fn: (r) => r._measurement == “TESTMEASUREMENT”)
|> filter(fn: (r) => r.id == “XXX”)
|> filter(fn: (r) => r._field == “YYY”)

Query 2:
from(bucket: “TESTBUCKET”)
|> range(start: 0)
|> filter(fn: (r) => r._measurement == “TESTMEASUREMENT” and r.id == “XXX” and r._field == “YYY”)

@Anaisdg , @scott , @grant1 tagging for attention :pray:

Hello @ajetsharwin,
They should be the same.

1 Like

The optimization it actually depends on your schema.

for example, if you only have 1 measurement in that bucket you can skip that filter.
If you have different tags with the same fields and you have in total more datapoints across tags than fields, then you should filter by fields first.

Use the filter that narrows down the most at the beginning. on most on my use cases its more efficient to filter by field first. but that is because that way y drop most of the data that I don’t need first.