看到这个关于SQL中加入 LIMIT 1
是否会更快的问题,/q/10100000001...
老牛我就想起了mongodb里的 findOne
db.collection.findOne(query)
不知道是不是跟SQL的一样,还是说跟db.collection.find().limit(1)
一样?
迷茫2017-04-21 11:17:25
The limit() function in mongoDB is the same as the limit in sql. The limit() function in mango is also used after the find() function.
伊谢尔伦2017-04-21 11:17:25
Although the implementation mechanism is not much different from db.collection.find().limit(1)
差距太多,但用起来和 db.collection.find().limit(1)
,
findOne
是 找到第一条,返回数据,然后关闭游标cursor 这些操作一气喝成db.collection.find().limit(1)
is to first return the cursor, obtain the required data, and then close the cursor
The specific implementation still depends on the client...