# Getting doc by \_id is slow

**URL:** <https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885>\
**Category:** Elasticsearch\
**Created:** [January 6, 2020, 12:01pm UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885 "2020-01-06T12:01:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenixtu](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@phoenixtu](https://discuss.elastic.co/u/phoenixtu)\
**Post date:** [January 6, 2020, 12:01pm UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885/1 "2020-01-06T12:01:04Z")

</div>

i am using the \_id to get doc in curl like `time curl http://host:port/index/type/id` , but the time cost can be vary much from 2ms~200ms, a time cost of 200ms is not ok for my situation where ~10ms will be wanted. i am wondering how this comes. can anyone explain the detail of getting doc by \_id, or how can i fasten the doc getting by \_id? thanks in advance.

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [January 6, 2020, 2:33pm UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885/2 "2020-01-06T14:33:51Z")

</div>

Are you accessing docs that are frequently updated or have just been indexed? Which ES version is this? Does performance improve when using `time curl http://host:port/index/type/id?realtime=false`

---

<div class="post-metadata">

**Author:** ![phoenixtu](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@phoenixtu](https://discuss.elastic.co/u/phoenixtu)\
**Post date:** [January 7, 2020, 2:36am UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885/3 "2020-01-07T02:36:06Z")

</div>

the docs i am accessing will not be updated after writing with only one key been indexed. the ES version i am using is 6.8.3. according to the es docs, doesn't the `realtime=false` slow down the performance?

---

<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:** [January 7, 2020, 6:21am UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885/4 "2020-01-07T06:21:44Z")

</div>

Curl need to establish a new connection per request which adds overhead, while most client libraries use long running connections to avoid this. If possible I would recommend you create a small script and see what impact eliminating connection setup from the request path has.

---

<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:** [February 4, 2020, 6:21am UTC](https://discuss.elastic.co/t/getting-doc-by-id-is-slow/213885/5 "2020-02-04T06:21:55Z")

</div>

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