# Would docvalues be loaded into jvm?

**URL:** <https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491>\
**Category:** Elasticsearch\
**Created:** [June 15, 2017, 3:18am UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491 "2017-06-15T03:18:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [June 15, 2017, 3:18am UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491/1 "2017-06-15T03:18:15Z")

</div>

hi  
I know that data is written into disk with the style of column-store if I enable doc-values for certain field.  
But I don't understand why sorting with docvalues doesn't increase the load of jvm. whatever sorting algorithm , data would be loaded into jvm to sort. This should be a high load for jvm when I sort all index , but no change for jvm in fact. How does lucene sort with docvalues ? Can sort algorithm work directly based on the file (Mmap) ?

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [June 16, 2017, 1:55am UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491/2 "2017-06-16T01:55:55Z")

</div>

> [@wangqinghuan](#):
>
> Can sort algorithm work directly based on the file (Mmap) ?

Essentially, yes. Lucene relies on the filesystem cache for keeping hot things in memory. The index files are loaded through mmap, so not directly into memory, hence it does not consume jvm heapspace.

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [June 16, 2017, 10:34am UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491/3 "2017-06-16T10:34:24Z")

</div>

when sorting with doc-values, does it works directly off filesystem cache? Sorting algorithm needs some addional spaces,does these spaces are malloced with filesystem cache ?

---

<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:** [June 16, 2017, 12:22pm UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491/4 "2017-06-16T12:22:48Z")

</div>

We do not sort all values, we only compute the top-k hits using a heap of size `from + size`. This heap is allocated in the JVM heap but is expected to be small.

---

<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 14, 2017, 12:22pm UTC](https://discuss.elastic.co/t/would-docvalues-be-loaded-into-jvm/89491/5 "2017-07-14T12:22:51Z")

</div>

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