promql-engine icon indicating copy to clipboard operation
promql-engine copied to clipboard

"Aggressive" optimizations mode

Open GiedriusS opened this issue 3 years ago • 5 comments

There are some optimizations that are not done in Prometheus PromQL engine due to backward compatibility. However, those use cases that they are trying not to break only really matter to a few percent of the users. Thus, I suggest adding some kind of new parameter to the engine which would add an optimization pass to the given PromQL expression. The results/behavior wouldn't be strictly compatible with the original PromQL but I think that doesn't matter to Thanos/Cortex/... users anyway.

Some candidates:

  • https://github.com/prometheus/prometheus/issues/8053
  • ... more?

GiedriusS avatar Oct 05 '22 06:10 GiedriusS

This makes sense. I did not understand why propagating labels across bin-ops is a breaking change though. We might want to document this well once we implement it.

fpetkovski avatar Oct 05 '22 07:10 fpetkovski

Because apparently there are "storages" which return data that does not strictly match the given matchers :smile: however, I think it's probably such a rare use-case that we could enable such optimizations by default.

GiedriusS avatar Oct 17 '22 06:10 GiedriusS

Makes sense to have this enabled by default in Thanos at least. It shouldn't be too hard to implement, we just need to handle the vector matching in cases like: metric_1 / on(label_1) group_left metric_2{label_2="value_2"}

fpetkovski avatar Oct 17 '22 13:10 fpetkovski

Happy to configure different optimizers in future. But it should case driven. I can't see anything "too aggressive" so far 🤔

bwplotka avatar Oct 31 '22 16:10 bwplotka

I guess we can close this issue as optimizers are already configurable?

yeya24 avatar Apr 16 '25 06:04 yeya24