Influx query takes so much time for one record

from(bucket: "navi-vts")
  |> range(start: 2025-02-07T11:14:11.565Z, stop: 2025-02-07T11:14:11.567Z)
  |> filter(fn: (r) => r["_measurement"] == "PositionReport")
  |>filter(fn: (r) => r["_field"] == "Latitude")

Hello @Younes_Askour,
Here are some possible reasons for slow query response times, do any apply to you?

  1. High cardinality
  2. Unoptimized indexing…queries that filter only by _measurement and _field may need to scan a large number of series. Indexing tags can help.
  3. Large dataset/many points–Even though your query range is small, InfluxDB might be scanning a large dataset due to inefficient filtering.
  4. HW/Backend storage–If ure running InfluxDB on slow disks or a system with high IO latency, queries may take longer.

Can you filter with a tag?

from(bucket: "navi-vts")
  |> range(start: 2025-02-07T11:14:11.565Z, stop: 2025-02-07T11:14:11.567Z)
  |> filter(fn: (r) => r["_measurement"] == "PositionReport")
  |> filter(fn: (r) => r["_field"] == "Latitude")
  |> filter(fn: (r) => r["MMSI"] == "257595708")  // Example of filtering by a tag

reduce scanning with limit?

from(bucket: "navi-vts")
  |> range(start: 2025-02-07T11:14:11.565Z, stop: 2025-02-07T11:14:11.567Z)
  |> filter(fn: (r) => r["_measurement"] == "PositionReport")
  |> filter(fn: (r) => r["_field"] == "Latitude")
  |> limit(n: 1)

Also: