user2010032
user2010032

Reputation: 21

Mongo db large number of documnets in a collection

I am using mongo db, right now I am having my data stored in mysql. Each row is unique and i want to shift the data in mongodb,

*so should i create separate document for each row or embed it in a array in chunks of 1000 per document ? *

The operations which i have to do frequently are

1) Update a specific field on a condition based on the unique id i have created 2) Delete it after a regular interval of time.

if need any more clarification on this please let me know

Upvotes: 1

Views: 57

Answers (1)

Miguel Cartagena
Miguel Cartagena

Reputation: 2606

You can do those operations on both models, but I really don't see why embed rows in a array. If each row is unique and represents an unique entry in your data model, there is no motivation to embed it in a array.

Embed arrays/objects are often used to store data that were on distinct tables, forcing to use a JOIN on each read operation. The classic example is tags entries on a blog post: theres is a posts table, a tags table and a relationship table called post_tags. In a document fashion, you just embed tags on post document.

Create a separated document for each row. It will save you deal with array index operations.

Upvotes: 1

Related Questions