vendredi 27 février 2015

How efficient is the MongoDB $in operator?


Vote count:

0




Let's say I will have millions of comments that are cross-posted to multiple points of interest. Should I store each cross-posted comment multiple time:



{
username: ...,
text: ...,
poi_id: some_id1
}
{
username: ...,
text: ...,
poi_id: some_id2
}


or should I do it as an array



{
username: ...,
text: ...,
poi_ids: [some_id1, some_id2]
}


The first can just use an index on poi_id and be blazingly fast. The second one makes more intuitive sense as a database structure, and saves space, but I'm worried about query efficiency of using $in if I want to, say, get all the comments associated with some_id1.



asked 54 secs ago







How efficient is the MongoDB $in operator?

Aucun commentaire:

Enregistrer un commentaire