Skip to content

Commit

Permalink
improve query speed when does not enable caching (grafana#2645)
Browse files Browse the repository at this point in the history
* improve query speed when does not enable caching

Signed-off-by: storyicon <storyicon@foxmail.com>

* Update pkg/chunk/cache/tiered.go

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
Signed-off-by: storyicon <storyicon@foxmail.com>

* simplify optimization

Signed-off-by: storyicon <storyicon@foxmail.com>

Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
  • Loading branch information
ussr-admin and codesome authored Jun 4, 2020
1 parent f9bd0fd commit 27f38a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cache/tiered.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ func NewTiered(caches []Cache) Cache {
return tiered(caches)
}

// IsEmptyTieredCache is used to determine whether the current Cache is implemented by an empty tiered.
func IsEmptyTieredCache(cache Cache) bool {
c, ok := cache.(tiered)
return ok && len(c) == 0
}

func (t tiered) Store(ctx context.Context, keys []string, bufs [][]byte) {
for _, c := range []Cache(t) {
c.Store(ctx, keys, bufs)
Expand Down
2 changes: 1 addition & 1 deletion storage/caching_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type cachingIndexClient struct {
}

func newCachingIndexClient(client chunk.IndexClient, c cache.Cache, validity time.Duration, limits StoreLimits) chunk.IndexClient {
if c == nil {
if c == nil || cache.IsEmptyTieredCache(c) {
return client
}

Expand Down

0 comments on commit 27f38a7

Please sign in to comment.