storage: add projection fields to select hints (#16423)

This commit adds Projection metadata to SelectHints so that downstream
storage implementations can use it to save effort when answering to
Select calls.

Signed-off-by: Michael Hoffmann <mhoffmann@cloudflare.com>
This commit is contained in:
Michael Hoffmann 2025-07-06 12:57:19 +02:00 committed by GitHub
parent f561aa795d
commit 21b1536b5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -223,6 +223,19 @@ type SelectHints struct {
// When disabled, the result may contain samples outside the queried time range but Select() performances
// may be improved.
DisableTrimming bool
// Projection hints. They are currently unused in the Prometheus promql engine but can be used by different
// implementations of the Queryable interface and engines.
// These hints are useful for queries like `sum by (label) (rate(metric[5m]))` - we can safely evaluate it
// even if we only fetch the `label` label. For some storage implementations this is beneficial.
// ProjectionLabels are the minimum amount of labels required to be fetched for this Select call
// When honored it is required to add an __series_hash__ label containing the hash of all labels
// of a particular series so that the engine can still perform horizontal joins.
ProjectionLabels []string
// ProjectionInclude defines if we have to include or exclude the labels from the ProjectLabels field.
ProjectionInclude bool
}
// LabelHints specifies hints passed for label reads.