I am running Influx Cloud 2.0.
I have a measurement where each field is a sensor posting data at differing intervals. For each field I want to get n amount of latest records.
For one record the flux query is:
from(bucket: "<bucket>")
|> range(start: 0, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "<measurement>")
|> last()
This executes instantly
but doing the same replacing last() with tail(n: 1) or a |> sort(columns: ["_time"], desc: true) |> limit(n: 1)takes over 7 seconds.
In InfluxQL (via the influx v1 shell and a DBRP) I get the same 7s performance when using:
SELECT LAST(*) FROM ProcessTimesPV
I cannot narrow the time window down. I cannot aggregate the values or lower the volume of data. I thought this to be a rather simple use case for a modern TSDB.
I assume the data is sorted by time in memory so why is it so hard getting the top elements.
According to Optimize Flux queries | InfluxDB OSS v2 Documentation the sort descending and limit should be a pushdown but apparently it’s not.

