Member-only story

MongoDB Performance 101: When & How You Should Use Partial Indexes

Tek Loon
8 min readJan 2, 2020

--

Photo by Denny Müller on Unsplash

This article was inspired when I am taking the MongoDB Performance Course exam. I thought I understood it quite well and turned out that my score was pretty bad. This leads me to write this article and allows me to study in-depth on the topic and at the same time relate it with a practical use case in today’s world.

What is Partial Index?

Partial index is the index where it only indexes a subset of your documents (data) in your collections. In laymen term, imagine you have a million record of data, but you would only want to index part of it, e.g, 500K.

Why Partial Index?

At this point, you might be thinking why would I do a partial index, why don’t I just index all of it.

You can do that but if the cost is high which will affect the performances and slow down your application. You definitely wouldn’t want this to happen especially when your data is growing fast.

Start giving a better User Experience by improving your application speed.

Implementing Partial Index resulted in two benefits:

  • Reduce Storage for Storing the Index
  • Lesser indexes lead to better write operation performances.

--

--

Tek Loon
Tek Loon

Written by Tek Loon

Coder and Writer. If you enjoy my stories— support me by https://www.buymeacoffee.com/tekloon so I can keep writing articles for the community.

No responses yet