Schema help

0 views
Skip to first unread message

Mark Fletcher

unread,
Dec 15, 2009, 5:46:51 PM12/15/09
to mongod...@googlegroups.com
Hi,

I have a large collection of documents, X. I have a bunch of users who
have specified which documents in X they are not interested in.
Generally this number of documents each user is not interested in is
much smaller than the total in X. The list of documents the users are
not interested in is stored in collection Y.

I want to return the N most recent documents a given user is
interested in. Is the best way to do this to use the $nin operator?
I'd grab a chunk of documents from X, and then check to see which ones
to ignore using a $nin query on Y? And then grabbing more documents
from X and repeating until I can return N documents? Assume every
document has an integer _id, fwiw.

Hope this makes sense.

Thanks,
Mark

Mathias Stearn

unread,
Dec 15, 2009, 6:28:11 PM12/15/09
to mongod...@googlegroups.com
I'd suggest grabbing the newest  N+m (or N*m) documents from X, then grabbing the documents from Y that are newer than the oldest document in that set. Remove the unwanted documents from the set, and repeat if the new set size is smaller than N. Adjust the value of m to minimize the chances of requiring a second fetch from X.


--

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.



Mark Fletcher

unread,
Dec 15, 2009, 6:51:45 PM12/15/09
to mongod...@googlegroups.com
Oh duh, that makes much more sense. Thanks.

Mark
Reply all
Reply to author
Forward
0 new messages