# Date histogram cache?

**URL:** <https://discuss.elastic.co/t/date-histogram-cache/184903>\
**Category:** Elasticsearch\
**Created:** [June 10, 2019, 1:54am UTC](https://discuss.elastic.co/t/date-histogram-cache/184903 "2019-06-10T01:54:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liujin](https://avatars.discourse-cdn.com/v4/letter/l/b487fb/32.png) [@liujin](https://discuss.elastic.co/u/liujin)\
**Post date:** [June 10, 2019, 1:54am UTC](https://discuss.elastic.co/t/date-histogram-cache/184903/1 "2019-06-10T01:54:39Z")

</div>

We hava huge amount of date histogram query, so i want to know whether the partial result of date histogram query can be cached.  
For example, i query avg(cost) of last 1 hour group by 1m interval at 01:00, and then i do a same query at 01:05. Can the result of 00:05~01:00 be cached? It can save CPU resource in a great measure  
Thanks!

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 14, 2019, 7:33pm UTC](https://discuss.elastic.co/t/date-histogram-cache/184903/2 "2019-06-14T19:33:47Z")

</div>

Some aspects of queries and aggregations are cached. Parts of the lucene query will internally cache so that finding the documents is faster in the future, aggregations have a "request cache" which caches agg responses, and the file system caches hot index files.

The request cache is particularly useful if there are many shards involved in a search. E.g. if you have an index-per-day and search the last 7 days, only the two ends of the 7 day range are likely to change. So the internal 5 days get cached and only the two end days are updated.

So the short answer is that yes, there is caching involved. We don't do fine-level caching though, since it is easy to fill a cache with values that are never used again and it causes a lot of churn. For that level we rely on the OS to keep hot mmapped index/doc value files in memory.

---

<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 12, 2019, 7:33pm UTC](https://discuss.elastic.co/t/date-histogram-cache/184903/3 "2019-07-12T19:33:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
