grafana / mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
https://grafana.com/oss/mimir/
GNU Affero General Public License v3.0
4.17k stars 535 forks source link

Idea: Cache subqueries the same way as range queries #10023

Open julienduchesne opened 5 hours ago

julienduchesne commented 5 hours ago

What is the problem you are trying to solve?

When querying an aggregated subquery as an instant query:

max_over_time({{query}}[7d:1h])

or the same `{{query}} as a range query, there is a dramatic different in performance. In my own use case, the aggregated instant query takes around 1m50s and the range query takes ~1-5s, while they are querying the same data (minus a max operation which should take microseconds)

Which solution do you envision (roughly)?

This difference in runtime is due to the fact that range queries are incrementally cached, while subqueries (as part of instant queries) are not cached at all (see https://github.com/grafana/mimir/issues/3815)

Using the range query cache for subqueries could lead to performance improvements, especially for ruler queries which often do aggregations over subqueries and are all instant queries

Have you considered any alternatives?

No response

Any additional context to share?

No response

How long do you think this would take to be developed?

Not sure

What are the documentation dependencies?

No response

Proposer?

@julienduchesne