index / best practice

39 views
Skip to first unread message

CCVonLewin

unread,
May 10, 2013, 8:17:50 PM5/10/13
to node-mong...@googlegroups.com
Greetings,

I have a collection which has 2k+ documents which look like;
{ id: #, item: string, sku: string, like: [ { id: # }, { id: # }, ... 900+ ], hate: [ { id: # }, { id: # }, ... 900+ ] }

I created an index based on 'id' since a lot of my queries are done using that property. Recently I've been querying on 'like.id' or 'hate.id' a lot and have been wondering if I should add those to the index?

Any advise would be great, thanks.

Wes Freeman

unread,
May 10, 2013, 8:36:12 PM5/10/13
to node-mong...@googlegroups.com
This question is probably better for the general mongodb group.

Yes, if you're querying on something it should usually have an index. If you only have 2k documents you might not see much improvement in query time, but it's still probably worth it.

Wes


--
You received this message because you are subscribed to the Google Groups "node-mongodb-native" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-mongodb-na...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Reply all
Reply to author
Forward
0 new messages