# Most Efficient way to fetch multiple records by their Id

**URL:** <https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 29, 2021, 8:32pm UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035 "2021-10-29T20:32:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spyros\_Giannopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spyros_giannopoulos/32/82772_2.png) [@Spyros\_Giannopoulos](https://discuss.elastic.co/u/Spyros_Giannopoulos)\
**Post date:** [October 29, 2021, 8:32pm UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035/1 "2021-10-29T20:32:51Z")

</div>

Hello,

I have a case where I need to fetch a huge number of records but I know already their Id. I'm using c# Nest library. What would be the most efficient way to fetch them? The size of the records can vary from a few records to more than 1m records (ids).

I have seen the MultiGetAsync and also utilising the SearchAsync by adding multiple times with the should operation the ids and making multiple calls to the cluster.

Best Regards,  
Spyros

---

<div class="post-metadata">

**Author:** ![Spyros\_Giannopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spyros_giannopoulos/32/82772_2.png) [@Spyros\_Giannopoulos](https://discuss.elastic.co/u/Spyros_Giannopoulos)\
**Post date:** [November 1, 2021, 10:05am UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035/2 "2021-11-01T10:05:00Z")

</div>

Hello,

Just to enlighten a bit more on the question, the fact that I'm using c# nest library shouldn't relate directly to the performance of the call rather the API that is called behind the scenes.

Let's say that I have 1m ids of the docs that I want to fetch. What would be the best way to fetch them? With a multiget (mget) call or rather with a search query or maybe some other way?  
What would be the most efficient way?

If I would like to make the performance of the call better, would the HD performance (IO speed) be the first thing I should focus to scale higher first?

Best Regards,  
Spyros

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 2, 2021, 11:29pm UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035/3 "2021-11-02T23:29:59Z")

</div>

Probably an `mget`, but at a million records, it's going to be expensive no matter what you do.

Faster IO would help, SSDs definitely.

---

<div class="post-metadata">

**Author:** ![Spyros\_Giannopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spyros_giannopoulos/32/82772_2.png) [@Spyros\_Giannopoulos](https://discuss.elastic.co/u/Spyros_Giannopoulos)\
**Post date:** [November 11, 2021, 4:16pm UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035/4 "2021-11-11T16:16:21Z")

</div>

Thank you a lot for the reply!

I am using already SSD and mget. It would be nice if I could even leverage that more though.

Best Regards,  
Spyros

---

<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:** [December 9, 2021, 4:16pm UTC](https://discuss.elastic.co/t/most-efficient-way-to-fetch-multiple-records-by-their-id/288035/5 "2021-12-09T16:16:56Z")

</div>

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