(zero V unu)

MongoDB more indexes on Secondaries

I’ve been wondering for a time if it works, the documentation is not really clear if you can have different indexes on a replicaset secondary, maybe delayed or with priority 0.

Using this feature you can do reports better on a secondary (maybe delayed too) secondary server. Make sure the journal is big enough to allow secondary indexes to be built.

Step 1: Build replica set

a. Here are the replica set config files:

b. Start servers

c. Configure replica set members

d. Add some data and indexes

Step 2. Separate node and add indexes

a. Remove node from replicaset

b. Stop server

c. Modify config outside the replica set

d. Start server

e. Add index

f. Meanwhile on the primary some inserts happen

Step 3. Rebuild replica set

a. Stop separated slave

b. Modify back the config

c. Start server again

d. Add back to replica set

e. Wait for synchronisation

f. Test queries on primary

g. Test queries on node 2

Didn’t have time for benchmarking, will do probably this in another post