From f35d0cd1e8dd7b34e963a7cb5dce48a49e9781b4 Mon Sep 17 00:00:00 2001 From: Bartek Plotka Date: Tue, 22 Oct 2019 13:10:09 +0100 Subject: [PATCH] querier: Actually use select mint,maxt params during select. This will definitely helps with offset queries. Same was done on https://github.com/cortexproject/cortex/pull/1012 Signed-off-by: Bartek Plotka --- pkg/query/api/v1.go | 5 +++-- pkg/query/querier.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/query/api/v1.go b/pkg/query/api/v1.go index 7f78587811..0152d18126 100644 --- a/pkg/query/api/v1.go +++ b/pkg/query/api/v1.go @@ -503,7 +503,8 @@ func (api *API) series(r *http.Request) (interface{}, []error, *ApiError) { } // TODO(bwplotka): Support downsampling? - q, err := api.queryableCreate(enableDedup, replicaLabels, 0, enablePartialResponse).Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end)) + q, err := api.queryableCreate(enableDedup, replicaLabels, 0, enablePartialResponse). + Querier(r.Context(), timestamp.FromTime(start), timestamp.FromTime(end)) if err != nil { return nil, nil, &ApiError{errorExec, err} } @@ -515,7 +516,7 @@ func (api *API) series(r *http.Request) (interface{}, []error, *ApiError) { sets []storage.SeriesSet ) for _, mset := range matcherSets { - s, warns, err := q.Select(&storage.SelectParams{}, mset...) + s, warns, err := q.Select(nil, mset...) if err != nil { return nil, nil, &ApiError{errorExec, err} } diff --git a/pkg/query/querier.go b/pkg/query/querier.go index dac3feab4b..4263d81a36 100644 --- a/pkg/query/querier.go +++ b/pkg/query/querier.go @@ -169,12 +169,18 @@ func (q *querier) Select(params *storage.SelectParams, ms ...*labels.Matcher) (s return nil, nil, errors.Wrap(err, "convert matchers") } + if params == nil { + params = &storage.SelectParams{ + Start: q.mint, + End: q.maxt, + } + } queryAggrs, resAggr := aggrsFromFunc(params.Func) resp := &seriesServer{ctx: ctx} if err := q.proxy.Series(&storepb.SeriesRequest{ - MinTime: q.mint, - MaxTime: q.maxt, + MinTime: params.Start, + MaxTime: params.End, Matchers: sms, MaxResolutionWindow: q.maxResolutionMillis, Aggregates: queryAggrs,