# How to improve performance of ID query

**URL:** <https://discuss.elastic.co/t/how-to-improve-performance-of-id-query/253699>\
**Category:** Elasticsearch\
**Created:** [October 29, 2020, 1:34pm UTC](https://discuss.elastic.co/t/how-to-improve-performance-of-id-query/253699 "2020-10-29T13:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjali\_zarkar](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@anjali\_zarkar](https://discuss.elastic.co/u/anjali_zarkar)\
**Post date:** [October 29, 2020, 1:34pm UTC](https://discuss.elastic.co/t/how-to-improve-performance-of-id-query/253699/1 "2020-10-29T13:34:27Z")

</div>

'Hi ,  
I am new to Elasticsearch, I am trying to fetch documents from eleasticsearch using Id query .  
Numbers of records in query are just 180 and query takes ~800 ms.

{  
"profile" : "true",  
"query": {  
"ids" : {  
"values" : ["3261", "3280", "5683", "5686", "6517", "6518", "19395", "19396", "19397", "19398", "19399", "19400", "19405", "19406", "19409", "19569", "19570", "100146", "100150", "104180", "104181", "104182", "104183", "500076", "500078", "500079", "500269", "500457", "500467", "500473", "601025", "601027", "601097", "601100", "601455", "601458", "601460", "601461", "601462", "601465", "620307", "620308", "620309", "620310", "700136", "700137", "700429", "700676", "700682", "704655", "704786", "704787", "704788", "705188", "705196", "705208", "705922", "705929", "766000", "766001", "766002", "766003", "766004", "837008", "837009", "861000", "861001", "896000", "896001", "896002", "896003", "899007", "1022000", "1022001", "1241000", "1256103", "1276000", "1276001", "1305115", "1305116", "1329100", "1332100", "1361101", "1361102", "1361103", "1361104", "1379100", "1379101", "1379102", "1379103", "1408105", "1408106", "1408107", "1408108", "1412102", "1412103", "1412104", "1412105", "1412106", "1478102", "1478103", "1494112", "1499100", "1499101", "1499102", "1499103", "1499104", "1499105", "1533101", "1533102", "1533103", "1541100", "1541101", "1542297", "1542298", "1542503", "1542504", "1543019", "1543020", "1543319", "1543320", "1544361", "1544362", "1544363", "1544364", "1544600", "1545333", "1545334", "1545718", "1545719", "1545782", "1545788", "1545806", "1545807", "1547521", "1547619", "1547620", "1547621", "1547622", "1547623", "1547624", "1547625", "1547626", "1547627", "1547628", "1547629", "1547630", "1547694", "1547784", "1547785", "1547786", "1547838", "1547839", "1547840", "1547841", "1547842", "1547843", "1548954", "1548955", "1548956", "1548957", "1548958", "1548959", "1548960", "1548961", "1548962", "1548963", "1548964", "1548965", "1548966", "1548967", "1548968", "1548969", "1548970", "1548971", "1548972", "1549428", "1549429", "1549430", "1549431", "1549432", "1549798", "1549926"]  
}  
}  
}

Any idea how to minimize response time to ~200 ms?

Thanks'

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 30, 2020, 9:12am UTC](https://discuss.elastic.co/t/how-to-improve-performance-of-id-query/253699/2 "2020-10-30T09:12:38Z")

</div>

Searches are broadcasted to all shards and executed.  
A GET by document ID is routed directly to only the one shard that might contain that document.

For bulk gets check out the [mget API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html)

(Also, just in case you didn't already realise - `profile:true` is expensive)

---

<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:** [November 27, 2020, 9:12am UTC](https://discuss.elastic.co/t/how-to-improve-performance-of-id-query/253699/3 "2020-11-27T09:12:43Z")

</div>

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