# Does pre-filtered approximate kNN still need entire data in memory?

**URL:** <https://discuss.elastic.co/t/does-pre-filtered-approximate-knn-still-need-entire-data-in-memory/341636>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [August 25, 2023, 2:35am UTC](https://discuss.elastic.co/t/does-pre-filtered-approximate-knn-still-need-entire-data-in-memory/341636 "2023-08-25T02:35:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![veesahni](https://avatars.discourse-cdn.com/v4/letter/v/8e7dd6/32.png) [@veesahni](https://discuss.elastic.co/u/veesahni)\
**Post date:** [August 25, 2023, 2:35am UTC](https://discuss.elastic.co/t/does-pre-filtered-approximate-knn-still-need-entire-data-in-memory/341636/1 "2023-08-25T02:35:04Z")

</div>

[This article on tuning approximate kNN](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-knn-search.html) states "You should ensure that data nodes have at least enough RAM to hold the vector data and index structures".

Does this still apply when doing [filtered kNN search](https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html#knn-search-filter-example)?

To be clear: if filtering is being used to significantly reduce the amount of data being queried at any one time, would we still need enough RAM to hold the entirety of the data in memory?

My guess - yes, still applies. Since shards have segments of HSNW graphs. And those graphs need to be in memory in their entirety for efficient querying. Even if we're running filtered queries.

---

<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:** [September 22, 2023, 2:35am UTC](https://discuss.elastic.co/t/does-pre-filtered-approximate-knn-still-need-entire-data-in-memory/341636/2 "2023-09-22T02:35:35Z")

</div>

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