-
Notifications
You must be signed in to change notification settings - Fork 10.3k
PromQL: optimise joins where a subexpression is step-invariant #9368
Copy link
Copy link
Open
Description
Proposal
In the blog post Introducing the '@' Modifier is this example:
rate(http_requests_total[1m]) # This acts like the actual selector.
and
topk(5, rate(http_requests_total[1h] @ end())) # This acts like a ranking function which filters the selector.
As I read the current PromQL code, the engine will evaluate topk(5, rate(http_requests_total[1h] @ end())) just once, replicate those results out to the length of the query range, then go step by step calling VectorAnd on those results.
But, since the rhs data doesn't change, that wastes a lot of work building a map on every step.
Perhaps we can modify the binary-op implementations to allow for one side being constant.
(Both sides constant is already optimised).
Reactions are currently unavailable