# Memory Usage in (Date) Histogram Facet

**URL:** <https://discuss.elastic.co/t/memory-usage-in-date-histogram-facet/7429>\
**Category:** Elasticsearch\
**Created:** [April 20, 2012, 10:56pm UTC](https://discuss.elastic.co/t/memory-usage-in-date-histogram-facet/7429 "2012-04-20T22:56:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [April 20, 2012, 10:56pm UTC](https://discuss.elastic.co/t/memory-usage-in-date-histogram-facet/7429/1 "2012-04-20T22:56:35Z")

</div>

Hi,

Reading "Memory Considerations" section at the bottom of  
[http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html](http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html) ....  
and want to confirm:

Just because you use the interval functionality to group values from a  
field in buckets does _not_ reduce the amount of memory needed.  
For example, if there are 1000 distinct values in field X, if you then do a  
histogram facet on X and bucket values into 100 buckets, the memory needed  
to hold this is still the same as if bu interval was used for bucketing.

In other words, even if you "bucketize", it is worth reducing the number of  
distinct values in a field by, for example, rounding up timestamps to  
minutes or hours or even days.

Is the above all correct?

## Thanks, Otis

Performance Monitoring for ES -  
[http://sematext.com/spm/elasticsearch-performance-monitoring](http://sematext.com/spm/elasticsearch-performance-monitoring)

---

<div class="post-metadata">

**Author:** ![drewr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewr/32/7803_2.png) [@drewr](https://discuss.elastic.co/u/drewr)\
**Post date:** [April 21, 2012, 3:21am UTC](https://discuss.elastic.co/t/memory-usage-in-date-histogram-facet/7429/2 "2012-04-21T03:21:53Z")

</div>

Otis Gospodnetic wrote:

> Reading "Memory Considerations" section at the bottom  
> of [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-)  
> facet.html .... and want to confirm:
> 
> Just because you use the interval functionality to group values from a  
> field in buckets does _not_ reduce the amount of memory needed.

[...]

> In other words, even if you "bucketize", it is worth reducing the  
> number of distinct values in a field by, for example, rounding up  
> timestamps to minutes or hours or even days.
> 
> Is the above all correct?

You are correct. Regardless of the interval, FieldDataLoader.load()  
will still populate a sparse matrix for every lucene segment defined  
by maximum docs in the segment by the number of unique terms in the  
field across all documents. And it gets worse once those segments  
are merged into fewer ones.

[facets OutofMemoryError · Issue #1531 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1531)  
[Question/comment about multi-value field data construction · Issue #1683 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1683)

-Drew

---

<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 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/memory-usage-in-date-histogram-facet/7429/3 "2017-07-06T03:31:37Z")

</div>

Closed on July 6, 2017, 3:31am UTC


