# Slow sorting on indexed \_id field

**URL:** <https://forums.foundationdb.org/t/slow-sorting-on-indexed-id-field/1148>\
**Category:** Document Layer\
**Created:** [February 18, 2019, 8:31pm UTC](https://forums.foundationdb.org/t/slow-sorting-on-indexed-id-field/1148 "2019-02-18T20:31:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![developer\_resource](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@developer\_resource](https://forums.foundationdb.org/u/developer_resource)\
**Post date:** [February 18, 2019, 8:31pm UTC](https://forums.foundationdb.org/t/slow-sorting-on-indexed-id-field/1148/1 "2019-02-18T20:31:36Z")

</div>

In testing document layer we are seeing very poor performance when sorting by `_id`, we have run createIndex/ensureIndex and while that eats all document layer cpu for a long time, we don’t see an improvement in performance after completion. The FoundationDB cluster itself is practically idle when either using sort on \_id or creating the index however document layer cpu is maxed. Other, keyed queries are very fast during both these actions showing that foundation db is not the bottle neck. Is there anything we are doing wrong or something we can do to improve performance on sort requests? We ask because these are very common uses of mongo according to our DBA team.

---

<div class="post-metadata">

**Author:** ![mbhaskar](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/mbhaskar/32/277_2.png) [@mbhaskar](https://forums.foundationdb.org/u/mbhaskar)\
**Post date:** [February 18, 2019, 10:32pm UTC](https://forums.foundationdb.org/t/slow-sorting-on-indexed-id-field/1148/2 "2019-02-18T22:32:09Z")

</div>

Yeah, this is one of the major issues we want to fix very soon. At the moment, document layer doesn’t use indexes for any `sort()`. This includes even the primary index, `_id`. Sorting happens on the documents in memeory. That is the reason why you see document layer being too busy while FoundationDB servers being idle

Targeting to fix this in next couple of releases. Here is the issue for it

> <https://github.com/FoundationDB/fdb-document-layer/issues/50>
