# Very few shard query cache hits

**URL:** https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752
**Category:** Elasticsearch
**Created:** [August 20, 2015, 11:07am UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752 "2015-08-20T11:07:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![widhalm\_t](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/widhalm_t/32/4290_2.png) [@widhalm\_t](https://discuss.elastic.co/u/widhalm_t)
#### Post date: [August 20, 2015, 11:07am UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752/1 "2015-08-20T11:07:54Z")

</div>

Hi!

I enabled the shard query cache on my indices and gave a bit more of the heap to this sort of cache in an Elasticsearch 1.7.1 cluster. When I repeatedly run a Kibana dashboard with lots of `terms` aggregations and line charts with `date histogram` aggregation with `count` or `unique` count on this cluster I expected to have many hits on this cache, at least when I use a timespan of `last 7 days`.

Instead Elasticsearch shows me about 80 hits and 12000 misses per node (I just had the nodes restarted).

This sort of cache should store all `count`results per shard, so when I query old shards I expect lots of hits. Did I misunderstand the shard query cache?

Cheers,  
Thomas

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [August 21, 2015, 3:28pm UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752/2 "2015-08-21T15:28:55Z")

</div>

This cache is invalidated every time that the index needs to be reopened, which could be every second if you keep on adding data to your index. Maybe this explains the issue you are seeing?

---

<div class="post-metadata">

### Author: ![widhalm\_t](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/widhalm_t/32/4290_2.png) [@widhalm\_t](https://discuss.elastic.co/u/widhalm_t)
#### Post date: [August 25, 2015, 9:12am UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752/3 "2015-08-25T09:12:08Z")

</div>

Thanks for your reply.

I have daily new indices and I don't write to old indices (at least I hope so, otherwise there would be lots of misconfigured NTP clients, out there), but I don't close them either, just to be sure.

I expect lots of misses when I do searches on todays index, but I would expect a lot more hits when I do searches over the last 7 days or 30 days. This is what keeps me wondering.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [September 1, 2015, 10:07pm UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752/4 "2015-09-01T22:07:48Z")

</div>

Hey,

do you see the cache in action when you specify fixed intervals? See [https://github.com/elastic/kibana/issues/2577](https://github.com/elastic/kibana/issues/2577) - I assume you are using kibana?

--Alex

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/very-few-shard-query-cache-hits/27752/5 "2017-07-05T23:52:48Z")

</div>


