Mongo’s sort problem

  mongodb, question

Recently, I used mongo and found a problem. in a certain collection, there is a ctime field in the document object, which is of MongoDate type. I made such a query db. find (). sort (‘ctime’:-1}). limit (10). it was found that the whole table was scanned once. if you want to be quick, you must build an index of {‘ctime’:-1}
图片描述

However, when using mysql, ctime does not build an index and the number of scans will not be very high, because I do not know much about the bottom layer of the database. I hope a great god can give me some advice, or maybe I used mongo incorrectly. the following are the details of mysql
图片描述

In order not to scan the entire table, the index is of course necessary, otherwise, how do you know that the ctime in other data must not be larger than the found data? As for MySQL, how do you know it doesn’t scan the entire table? MySQL’s data storage is compact, it scans much faster than Mongo, and MySQL has an advantage when there is no index.

One of Mongo’s great advantages lies in its rich query methods. To show Mongo’s characteristics, a reasonable and necessary index is essential.