# ES operations and memory usage

**URL:** <https://discuss.elastic.co/t/es-operations-and-memory-usage/16615>\
**Category:** Elasticsearch\
**Created:** [March 26, 2014, 2:41pm UTC](https://discuss.elastic.co/t/es-operations-and-memory-usage/16615 "2014-03-26T14:41:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uli\_Bethke](https://avatars.discourse-cdn.com/v4/letter/u/a183cd/32.png) [@Uli\_Bethke](https://discuss.elastic.co/u/Uli_Bethke)\
**Post date:** [March 26, 2014, 2:41pm UTC](https://discuss.elastic.co/t/es-operations-and-memory-usage/16615/1 "2014-03-26T14:41:44Z")

</div>

I am struggling a bit to understand which ES operations use up which part  
of memory

- From reading the documentation I know that faceting and sorting take up  
heap memory and also that some filters are cached in JVM heap. However,  
what other operations take up JVM heap memory?
- When faceting on a particular field are all of the values of that field  
loaded into JVM heap or only the distinct values of the field. I would  
believe it is the latter as fields of high cardinality require more JVM  
heap.
- What operations use OS memory. I believe documents retrieved and ES index  
are kept in OS memory. Can anyone confirm this? What other operations go to  
OS memory?

Finally, I would also be interested if there are any posts or tutorials  
that desribce the complete lifecycle of a query from submission of query to  
return of resultset.

Thanks  
Uli

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/561712ab-e11b-454f-b95e-38612cbb8db1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/561712ab-e11b-454f-b95e-38612cbb8db1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 26, 2014, 3:47pm UTC](https://discuss.elastic.co/t/es-operations-and-memory-usage/16615/2 "2014-03-26T15:47:02Z")

</div>

- Fielddata (sorting, facets, some scripting), filter cache (filters), and  
id\_cache (parent-child) are probably the ones that would affect memory  
usage significantly.
- Fielddata can be loaded in different ways depending on data type and  
other config (details here:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/fielddata-formats.html#_fielddata_loading))
- OS memory would generally be file system caches for the underlying Lucene  
indexes

About your other question, the default query execution is called  
query\_then\_fetch  
([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html#query-then-fetch)).  
The basic idea is the search (query) is scattered in parallel to all shards  
(single replica set) of an index being searched. Then a little bit of  
results are gathered back, reduced, and then sorted. Then whatever is the  
final reduced list, ES goes back to the final shards and pulls out (fetch)  
additional data required to return final hits to the caller.

On Wednesday, March 26, 2014 10:41:44 AM UTC-4, Uli Bethke wrote:

> I am struggling a bit to understand which ES operations use up which part  
> of memory
> 
> - From reading the documentation I know that faceting and sorting take up  
> heap memory and also that some filters are cached in JVM heap. However,  
> what other operations take up JVM heap memory?
> - When faceting on a particular field are all of the values of that field  
> loaded into JVM heap or only the distinct values of the field. I would  
> believe it is the latter as fields of high cardinality require more JVM  
> heap.
> - What operations use OS memory. I believe documents retrieved and ES  
> index are kept in OS memory. Can anyone confirm this? What other operations  
> go to OS memory?
> 
> Finally, I would also be interested if there are any posts or tutorials  
> that desribce the complete lifecycle of a query from submission of query to  
> return of resultset.
> 
> Thanks  
> Uli

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/dbe09764-67e8-49cd-98e7-9c9b5e4a801a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dbe09764-67e8-49cd-98e7-9c9b5e4a801a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:40am UTC](https://discuss.elastic.co/t/es-operations-and-memory-usage/16615/3 "2017-07-06T01:40:31Z")

</div>

Closed on July 6, 2017, 1:40am UTC


