我知道 Mysql 用 count 的时候如果数据量大会很慢.
如果我在 mongodb 里用 .length 性能会怎么样呢?
光阴似箭催人老,日月如移越少年。
In mongodb, query performance still depends on whether the entire document needs to be traversed and whether to create an index.
It will be just as slow as the amount of data is large. For example: it took 0.001s to count 1,000 items, and 0.1s to count 1,000,000 items. It's faster if you have an index. As the amount of data increases, all kinds of problems arise.
In mongodb, query performance still depends on whether the entire document needs to be traversed and whether to create an index.
It will be just as slow as the amount of data is large. For example: it took 0.001s to count 1,000 items, and 0.1s to count 1,000,000 items. It's faster if you have an index. As the amount of data increases, all kinds of problems arise.