This article documents how to improve MongoDB query performance using index selectivity. At the end of this article, you will know the importance of index selectivity and how you can leverage it in improving query performance.
Let’s explore the scenario we’re facing currently. We have a flight database with a booking
collection. Refer to the screenshot below for the schema.
Schema for booking
Given a flight database with a booking
collection, the admin from the flight company would want us to look into the query performance. Here is what the admin would do:
booking_no
, origin
, destination
, and the number of stop
.Next, I will analyze and list what I need in order to carry out the research.
I always start with finding out what I need in order to continue the research. These items are what I need:
At the end of the article, we will know the importance of index selectivity in query performance.
Without further ado, let’s start the experiment to check performance.
#mongodb #software-engineering #devops #programming #database