$in operator

Showing 1-4 of 4 messages
$in operator Revant Jain 5/1/12 12:45 PM
suppose i use

db.test.find("{ num : { $in : [1, 2, 3] }")

is the search going to to sequential O(n), is sorted array is passed
can search be binary with O(log(n))?
Re: [mongodb-user] $in operator Eliot Horowitz 5/1/12 7:37 PM
It'll basically do each one in serial.
A regular query like { num : 1 } is log(n) (where n = size of collection.
So it would be O( m * log(n) ) where m is the size of the $in array
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
unk...@googlegroups.com 5/2/12 12:04 AM <This message has been deleted.>
Re: [mongodb-user] $in operator Andreas Jung 5/2/12 12:10 AM
Well, create an index and you are fine :-)

-aj

Revant Jain wrote:
> suppose,
>
> db.test.find({ num : { $in : [1,2,3,4] } });
>
> if the array has over 100 elements, is the array search against num
> field sequential (O(n)) or binary (O(log(n))?
>

--
ZOPYX Limited           | zopyx group
Charlottenstr. 37/1     | The full-service network for Zope & Plone
D-72070 T�bingen        | Produce & Publish
www.zopyx.com           | www.produce-and-publish.com
------------------------------------------------------------------------
E-Publishing, Python, Zope & Plone development, Consulting