# Sorting on large mongo collections

**URL:** <https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291>\
**Category:** Help me!\
**Created:** [November 12, 2020, 3:21am UTC](https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291 "2020-11-12T03:21:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liam\_Cheung](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/liam_cheung/32/140_2.png) [@Liam\_Cheung](https://community.forestadmin.com/u/Liam_Cheung)\
**Post date:** [November 12, 2020, 3:21am UTC](https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291/1 "2020-11-12T03:21:50Z")

</div>

## Expected behavior

When sorting on large collections the query does not timeout

## Actual behavior

In my production environment query times out when sorted, but removing the sort now is responsive. When I run from a different environment accessing the same collection sorting does not impact the performance. Was not sure if there are some issues with version of node or other library where you have seen this before.

## Failure Logs

Please include any relevant log snippets, if necessary.

## Context

Please provide any relevant information about your setup.

```
"database_type": "MongoDB",
"liana": "forest-express-mongoose",
"liana_version": "6.3.9",
"engine": "nodejs",
"framework": "other",
"framework_version": null,
"orm_version": "5.9.29"

```

My local environment uses node “14.15.0”,  
But production environment uses node “10.23.0”,

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [November 12, 2020, 10:01am UTC](https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291/2 "2020-11-12T10:01:33Z")

</div>

Hello @Liam_Cheung,

If I understand correctly, the issue only appears in your production environment, right?  
Do the others environments where it works have the same amount of data, or is it a reduced one?

Do you use pagination for getting your records? Maybe it can be a solution.

Let me know 🙂

---

<div class="post-metadata">

**Author:** ![Liam\_Cheung](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/liam_cheung/32/140_2.png) [@Liam\_Cheung](https://community.forestadmin.com/u/Liam_Cheung)\
**Post date:** [November 15, 2020, 6:25pm UTC](https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291/3 "2020-11-15T18:25:09Z")

</div>

Same data set same size of data. Default pagination, the same in both environments.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [November 16, 2020, 10:31am UTC](https://community.forestadmin.com/t/sorting-on-large-mongo-collections/1291/4 "2020-11-16T10:31:05Z")

</div>

Hi @Liam_Cheung,

Okey and that column you are sorting on, do you have an index in one of yourDB and not the other ?  
Or should I say do you use the exact same DB version in both environment or is there ANY difference between the two 🤔 ?
