Building and managing indexes
Indexes can be built using the MongoDB shell or any of the available drivers.
MongoDB was used to build indexes in the foreground (using faster, blocking operations) or the background (using slower, non-blocking operations) up until version 4.4.
From this version onward, all indexes are now built using an optimized build process, which is at least as fast as the slower background build option present in previous versions.
The fewer inserts and updates that occur during the build process, the faster the index creation will be. Few to no updates will result in the build process happening as fast as the former foreground build option.
Index builds now obtain an exclusive lock at the collection level only for a short period at the beginning and the end of the build process. The rest of the time, the index build yields for read-write access.
An index constraint violation occurring from documents pre-existing to the build index command or being...