Understanding MongoDB Index

Getting a performance boost with the best usage of indexes, by understanding what’s the data structure, how it work’s/stored, how is it loaded into memory. How Query optimization make’s decision to select indexes.

  • Data Structure
  • Storage on disk
  • Memory Allocation.

Data Structure

Index on a filed/fields is stored in order that we specify using B-Tree data structure. Stored in ordered Let see what does it mean’s and how it help’s.


taken from https://docs.mongodb.com/manual/sharding/

MongoDB Sharding

Yes sharding horizontally scale our database, sharding is simplified abstraction to the complexity that MongoDB handles for us, for which in many cases we have better alternative.

Content

  • Sharing Experience.
  • Reason not to Shard.
  • Before you go for Sharding.
  • When Sharding what to take in account.
  • Use Case

Sharing Experience:

Everything comes with pros/cons, what we do as a software engineer we have to find what’s the best fit.
Our team had already…


M320,https://university.mongodb.com/

MongoDB Data Modeling

MongoDB bring whole world of Data Modeling as in SQL defining Schema before hand where in most of the time Normalization is the only way to model the data.

As beginner to MongoDB and Data modelling what to look for.

  • Importance of Data Modeling.
  • Data Modeling Methodology.
  • Modeling for Simplicity vs Performance.
  • Avoid over-engineering.

Data Modeling Introduction

as per mongodb documentation: The key challenge in data modeling is balancing the needs of the application, the performance characteristics of the database engine, and…


Photo by Braden Collum on Unsplash

Keep it simple

Why wait, fail it’s the simplest way to prepare for success.

It’s better to fail again and again, to wait to be ready.

It’s better to run, than not to run because of the fear that I am not prepared and might fail. It’s the best, fastest and easiest way possible to get prepared. …


MongoDB Storage Optimization

We can save on disk/memory depends on the document size number of fields their length and the size of the value assigned.

This is an easy small straightforward change not used much, We might not want to shorten the field-name/enum values present for the existing collection, but keeping this in mind when creating a new collection will help, will see how.

Why?

  • Filed name size/length contributes to the document size as MongoDB stores…


MongoDB multitenancy.

MongoDB with Spring Boot, Spring MVC multi-tenant DB with implementation pushed in www.github.com.

Why multi-tenant database ?

Few of the reasoning we had gone with multi-tenant DB.

  • Noisy-neighbor — If the nature of the data where there is clear separation(where you won’t aggregate/operate the two data together) ex- mars(citizens), earth(citizens) so even for citizens collection will keep that in there own database.


MongoDB Cluster

MongoDB setting up Sharded cluster for windows with a double click.

Introduction to Sharded cluster.

Sharding is a method for distributing data across multiple machines. …


snipped from: https://docs.mongodb.com/manual/replication/

MongoDB Cluster

MongoDB Read from secondaries, Use cases, reading stale-data/up-to-date-data from secondaries pro’s and con’s with example.

Why do we want to read from Secondary node’s ?

By default mongodb read/write on the primary for consistency(considering all preferences and configuration).

Use Cases to read from secondaries:

  • Reporting/analytics where in stale data is acceptable.
  • Write is significantly low compared to Reads(still have to take care…


Every thing start/stay’s simple until we make it complex/difficult.

I always did thing when it get’s most difficult to do, even if I was told to do simple thing’s daily… I knew that but for some reason I don’t like simple things……….. Still struggling to get the simple things done before it piles up to become difficult/complicated/undo-able.

For me I am still trying to keep thing’s simple :) Yes simple super simple. Just start cleaning your room from the place you see the closest slow and steady, don’t waste your time thinking analyzing from where to start to be most efficient.

Arun Pratap

Programmer, Database enthusiast currently exploring/learning MongoDB.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store