Timeline of 2 index builds on 93 million collection

I’ve recently started building, and recreating indexes on large collections with 104 million documents, which has taken from 21:00 to 05:30 to complete - in a 5 member replica set it does the shutdown/collection scans 2 secondaries at a time which speeds up the process.

What I am wondering is if I were to create 2 different indexes on the same collection of 93 million documents, would it use the same collection scan for both indexes to be created or rescan the collection for each separate index?

ultimately, should I separate the 2 index builds on the same collection to separate nights or will both complete in one night?

Each index is scanned separately. So don’t recommend it when you create it at the same time

Hi @Gareth_Furnell

Yes it will use the same pass to create multiple indexes. With the mongosh createIndexes method all the indexes options have to be the same. Otherwise the database command createIndexes can be used but the syntax is more verbose.

1 Like

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