02.10.2015 Views

The Little Mongo DB Schema Design Book

The Little Mongo DB Schema Design Book - Leanpub

The Little Mongo DB Schema Design Book - Leanpub

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

One-To-Many (1:N) 8<br />

13 blog_entry_id: 1,<br />

14 page: 2,<br />

15 count: 1,<br />

16 comments: [{<br />

17 name: "John Page",<br />

18 created_on: ISODate("2014-01-01T11:01:22Z"),<br />

19 comment: "Not so awesome blog"<br />

20 }]<br />

21 }<br />

<strong>The</strong> main benefit of using buckets in this case is that we can perform a single read to fetch 50<br />

comments at a time, allowing for efficient pagination.<br />

When to use bucketing<br />

When you have the possibility of splitting up your documents into discreet batches, it<br />

makes sense to consider bucketing to speed up document retrieval.<br />

Typical cases where bucketing is appropriate are ones like bucketing data by hours, days<br />

or number of entries on a page (such as comments pagination).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!