Minimongo findOne time differencess


#1

On the Client

var doc = someCollection.findOne( key ) // Fast
vs
var doc = someCollection.findOne( { _id: key } ) // Slow

Why completion times are different?


#2

There’s a special case for when the selector is just an _id string, in which case the collection works more like a hash map than like an array.

We should probably add this case for the { _id: "x"} form as well, but for now just use the “shorthand” for the faster speed.

See the code here: https://github.com/meteor/meteor/blob/676a9fa0fddb6a823c11cb1bfecfc533dd797373/packages/minimongo/minimongo.js#L96-L107


#3

Yes you are right, same speed. (_id: ‘X’) == (X)
The slow one is (uniqueField: ‘X’). Appx 4 times slower.


#4

Fixed it: https://github.com/meteor/meteor/pull/4404