How does MongoDB sort records when no sort order is specified?

前端 未结 2 756
盖世英雄少女心
盖世英雄少女心 2020-11-22 04:32

When we run a Mongo find() query without any sort order specified, what does the database internally use to sort the results?

According to the documentation on the m

2条回答
  •  一整个雨季
    2020-11-22 05:01

    It is returned in the stored order (order in the file), but it is not guaranteed to be that they are in the inserted order. They are not sorted by the _id field. Sometimes it can be look like it is sorted by the insertion order but it can change in another request. It is not reliable.

提交回复
热议问题