# Where the KNN index is stored?

**URL:** <https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [September 2, 2023, 5:24am UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157 "2023-09-02T05:24:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![panivan99pl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/panivan99pl/32/125216_2.png) [@panivan99pl](https://discuss.elastic.co/u/panivan99pl)\
**Post date:** [September 2, 2023, 5:24am UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157/1 "2023-09-02T05:24:58Z")

</div>

Where is the KNN index stored, in RAM or disk memory ?  
I came across that I used to use ChromaDB to store vectors, I had about 1 million vectors and it stores them all in RAM, it took about 24gb. That's too much, and I'm hoping elastik stores the vectors and index on disk, and still have a fast search.  
Where does elastiс store the vector index for fast search ?  
Wouldn't it be a problem that as the number of vectors grows, the RAM consumption will increase a lot ?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 3, 2023, 10:09am UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157/2 "2023-09-03T10:09:21Z")

</div>

Have a look at the [docs around estimating resource usage](https://www.elastic.co/guide/en/elasticsearch/reference/8.9/tune-knn-search.html#_ensure_data_nodes_have_enough_memory) for knn.

---

<div class="post-metadata">

**Author:** ![panivan99pl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/panivan99pl/32/125216_2.png) [@panivan99pl](https://discuss.elastic.co/u/panivan99pl)\
**Post date:** [September 5, 2023, 12:58pm UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157/3 "2023-09-05T12:58:11Z")

</div>

Do you think absolutely all vectors are stored in RAM, or does the elastiс somehow distribute the data partly on disk, partly on RAM ?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [September 5, 2023, 1:18pm UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157/4 "2023-09-05T13:18:04Z")

</div>

I believe the link I provided states that the data is stored on disk, but that it for performance reasons is important that it fits in the operating system page cache (not heap). As the size of data grows it will at some point exceed what can be kept in the page cache and performance is likely to degrade as disk I/O becomes a limiting factor.

---

<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:** [October 3, 2023, 1:18pm UTC](https://discuss.elastic.co/t/where-the-knn-index-is-stored/342157/5 "2023-10-03T13:18:57Z")

</div>

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