0

I'm loving RethinkDB!

I have a quick question in regards to efficiency of fetching data. I'm building a CRUD model for managing people's contacts.

Making one document containing an array of all the userID's contacts and access it by the primary index (the userID)

OR

Making one document for each contact of the userID and access it by a secondary index (the userID)

I'm trying to imagine how this would play out when there's 10,000 users and about 100,000 unique contacts.

Thank you!!!

Robert Laverty
  • 186
  • 2
  • 10
  • 1
    We had another question about embedding vs joinning http://stackoverflow.com/questions/32876366/rethinkdb-survey-modelling Your question is very similar in manner of deciding which way to go. You may want to read that answer because it contains some external reference. – kureikain Oct 01 '15 at 19:23
  • thank you! great read there – Robert Laverty Oct 05 '15 at 03:33

1 Answers1

0

To answer your question fully I think we'd need some more information regarding access patterns. I would say if you read the contacts often as an integral part of your application, then you should embed them in an array. But if you also update them frequently, then I would highly recommend a separate table for the contacts and performing a join when getting these data as updating indices of an embedded array is not a fast or easy operation.

Furthermore, I'm going to point you towards some links that may help:

dalanmiller
  • 3,467
  • 5
  • 31
  • 38
  • 1
    Thanks for the help! I took your advice and went with each contact item having its own doc then using secondary indexes to group a user's contacts. With RethinkDB 2.2 out, the secondary indexing performance is incredible! Thank you!!! – Robert Laverty Nov 19 '15 at 12:19