What load can multiple compound index put on my MongoDB server?

I have a huge collection. I need to create multiple compound indexes to filter/search or do multiple ETL operations on that collection.
Compound Index List:

  1. _id
  2. _id, name
  3. name, phone_number, contact_number,
  4. _id, name, address, pincode, phone_number, contact_number, countryName

I have created multiple compound indexes because multiple queries run at different times.
Is it the correct way to create compound indexes?
Will it increase the load on my MongoDB server?

these two can be removed, as they are not needed. You already have the last one which supports these two at the same time. https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound/#index-prefixes

Sure yes, maintaining index consumes resources, and slows down write path a bit.


_id is a required index. It can be whatever you want* as long as it is unique in the collection.

*though not an array

I completely forgot this for unknown reason. :rofl:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.