Sorting on large mongo collections

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.


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”,

1 Like

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 :slight_smile:

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

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 :thinking: ?