Hiding Index Replication Ops Manager

Hi There

Working with ops manager for a client that has a high amount of indexes on a highly used collection - the maximum is 64 and they are reaching close at 51, I have done an extensive analysis with $indexStats on which indexes are unused - which are redundant and came up with a list of 30 for them to drop - although some jobs that use these indexes run once every 3 months, so more communication on the importance of those is to come.

But i am thinking of hiding 5 indexes at a time to see the impact and if any spikes occur, to just unhide them - I see that on OPs Manager there is only a button to drop indexes - I am comfortable with Hiding Indexes through the command line, and if you could confirm for me - hiding indexes does replicate to secondaries once done on the primary correct?

Was just wondering that a hide index button on ops manager would be a great addition/feature if Ops Manager is still being worked on

Kindest Regards
Gareth Furnell

Hi @Gareth_Furnell,
You can use MongoDB compass for hide the indexes, as you can see in the following picture:

is correct, once the index is hidden in the primary, the operation is replicated by the secondary.
Here are the tests I performed:
connected to the primary and hidden the index:

MongoDB Enterprise rs0:PRIMARY> show dbs
admin    0.000GB
config   0.000GB
local    0.429GB
student  0.000GB
twitter  2.006GB
MongoDB Enterprise rs0:PRIMARY> use twitter
switched to db twitter
MongoDB Enterprise rs0:PRIMARY> show collections
twitter_collection
MongoDB Enterprise rs0:PRIMARY> db.twitter_collection.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "text" : 1
                },
                "name" : "text_1"
        }
]
MongoDB Enterprise rs0:PRIMARY> db.twitter_collection.hideIndex("text_1")
{
        "hidden_old" : false,
        "hidden_new" : true,
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1705447004, 8943),
                "signature" : {
                        "hash" : BinData(0,"PUJ2EKNvY2uWWZIAFg4aGCdo9gY="),
                        "keyId" : NumberLong("7280767374075101190")
                }
        },
        "operationTime" : Timestamp(1705447004, 8943)
}
MongoDB Enterprise rs0:PRIMARY> db.twitter_collection.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "text" : 1
                },
                "name" : "text_1",
                "hidden" : true
        }
]

Connected to secondary for verify if the index is hidden:

MongoDB Enterprise rs0:SECONDARY> use twitter
switched to db twitter
MongoDB Enterprise rs0:SECONDARY> db.setSecondaryOk()
MongoDB Enterprise rs0:SECONDARY> show collections
twitter_collection
MongoDB Enterprise rs0:SECONDARY> db.twitter_collection.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "text" : 1
                },
                "name" : "text_1",
                "hidden" : true
        }
]

Best Regards

2 Likes

Hi @Fabio_Ramohitaj

Thanks for the view of Compass - I’ve tried to connect to the cluster via Compass but receive timeouts or ssl errors, I need to double check what is necessary to connect to this cluster.

We’ll be doing the mongosh commands since we are comfortable with it and when it is approved, thanks again for testing too

Kindest Regards
Gareth Furnell

1 Like

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