I am managing version 5.0.9 cluster, recently while executing index creation queries with background = true option was taking long time but after removing that option , got executed immediately. As per documentation, that option should not have any effect but howcome it worked in this version ?
Hi @Nagarajan_Ponnusamy and welcome to the community!
In a replica set, you can create the index in the following way:
About your question, the answer is detailed here:
Regards
Hi @Fabio_Ramohitaj
Thank you for your response.
Yes, I can understand that this option not supposed to have any effect in index creation as per documentation.
Recently I came across this real time use case, where customer was trying to execute index creation query with that option through their application and it was taking more than 10 hours still query was not successfully executed. but we executed the query without the background option. To our surprise, the query executed immediately, without any noticeable delay. So all the index creation queries were executed without that option and we were able to create indexes immediately.
The issue was resolved, but this outcome prompted a critical question: why did removing the background option alleviate the issue, which was not supposed to have any effect on index creation from version 4.2?
Hi @Nagarajan_Ponnusamy,
I honestly don’t have an answer to your question
first two paragraphs this link takes you tells in short what was it and what has changed
though it is from 5.0 manual, this (or similar) only-lock-collection feature comes from 4.2 onward.
for your question, “why it was slow”, it is most probably because your database/collection was in constant use, and the indexing process had to wait for a quiter time interval.