# ES query for huge set of records gives Out Of Memory error

**URL:** <https://discuss.elastic.co/t/es-query-for-huge-set-of-records-gives-out-of-memory-error/20700>\
**Category:** Elasticsearch\
**Created:** [November 12, 2014, 4:22am UTC](https://discuss.elastic.co/t/es-query-for-huge-set-of-records-gives-out-of-memory-error/20700 "2014-11-12T04:22:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vipins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vipins/32/979_2.png) [@vipins](https://discuss.elastic.co/u/vipins)\
**Post date:** [November 12, 2014, 4:22am UTC](https://discuss.elastic.co/t/es-query-for-huge-set-of-records-gives-out-of-memory-error/20700/1 "2014-11-12T04:22:12Z")

</div>

Hi,

In my application, i have huge set of records in ES. I am querying 500000  
records and writing to a file, it is working fine. After the file has been  
generated, I tried the same query. But the memory is not released because  
of the first query, SO i am getting out of memory error.

I have below questions as part of the current scenario;

1. What kind of query should i use for large set of queries. Currently I  
am using boolenquery and also springESTemplate.
2. How to release memory after executing query

Please help me out. Thanks.

--  
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/69b52e94-f408-407c-98b3-0c837550a8bc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/69b52e94-f408-407c-98b3-0c837550a8bc%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, 12:50am UTC](https://discuss.elastic.co/t/es-query-for-huge-set-of-records-gives-out-of-memory-error/20700/2 "2017-07-06T00:50:37Z")

</div>

Closed on July 6, 2017, 12:50am UTC


