Does "db.collection.hideIndex" cause a resource lock?

Running “db.collection.dropIndex” cause a resource lock, which means that all read / write operations to the target collection are locked until deletion is completed.
Does “db.collection.hideIndex” cause the same effect?

Hi @Gabriel_Ayres welcome to the community!

While the locking behaviour of dropIndex is clearly documented, I don’t think hideIndex follows the same pattern.

hideIndex, I believe, just puts a flag on the associated index so the query planner is not considering it. It’s typically a step before actually dropping the index, to ensure that there are no negative performance consequences without that index. The ticket is SERVER-9306 if you want to see more details on this.

Best regards
Kevin

1 Like

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

Further details on hideIndex method: it’s an alias to the database command of the same name. It executes a collMod command in the background, which obtains an exclusive lock on the parent database of the specified collection for the duration of the operation. However in normal operations, this should be a quick process vs. the dropIndex command, thus the lock should only be held for an instant.

Kevin