21. How will you use it?
• The best way to use MongoDB is to tailor
your schema to how it will be used
22. How will you use it?
• The best way to use MongoDB is to tailor
your schema to how it will be used
• Things to consider:
23. How will you use it?
• The best way to use MongoDB is to tailor
your schema to how it will be used
• Things to consider:
• minimize reads and/or writes
24. How will you use it?
• The best way to use MongoDB is to tailor
your schema to how it will be used
• Things to consider:
• minimize reads and/or writes
• more writes, fewer reads? (read heavy)
25. How will you use it?
• The best way to use MongoDB is to tailor
your schema to how it will be used
• Things to consider:
• minimize reads and/or writes
• more writes, fewer reads? (read heavy)
• more reads, fewer writes? (write heavy)
27. How will you use it?
• Combine objects into one document if you
will use them together.
28. How will you use it?
• Combine objects into one document if you
will use them together.
• Example: Authors and Books
29. How will you use it?
• Combine objects into one document if you
will use them together.
• Example: Authors and Books
• Separate them if they need to be used
separately -- but beware, no joins!
30. How will you use it?
• Combine objects into one document if you
will use them together.
• Example: Authors and Books
• Separate them if they need to be used
separately -- but beware, no joins!
• Or duplicate the data -- but beware!
33. Precompute!
• Philosophy: do work before reads occur
• Disk space is cheap - compute time is not
(it’s expensive because users wait)
34. Precompute!
• Philosophy: do work before reads occur
• Disk space is cheap - compute time is not
(it’s expensive because users wait)
• Do joins on write, not on read
35. Precompute!
• Philosophy: do work before reads occur
• Disk space is cheap - compute time is not
(it’s expensive because users wait)
• Do joins on write, not on read
• Do complex aggregation ahead of time
36. Precompute!
• Philosophy: do work before reads occur
• Disk space is cheap - compute time is not
(it’s expensive because users wait)
• Do joins on write, not on read
• Do complex aggregation ahead of time
• Optimize for specific use cases
37. Precompute!
• Philosophy: do work before reads occur
• Disk space is cheap - compute time is not
(it’s expensive because users wait)
• Do joins on write, not on read
• Do complex aggregation ahead of time
• Optimize for specific use cases
• Delayed data is not always bad in real life