Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

indexStats - Behavior on UNIQUE indexes

I’ve asked the following in the MongoDB University and was referred here:

Hi, playing with Compass I’ve noticed that if you use _id field in Find()
the indexStats accesses.ops field increases by 2, what is the explanation for this behavior? is it the same for all unique indexes matches?

Another thing, when using INSERT on a unique index field, I’d expect the accesses.ops to increase by 2 as the index uniqueness must be verified and only then inserted.
(and if the index is found to be duplicated an increase by 1 only)

I’d appreciate a clarification.
Thanks,
Gal

Bump. still couldnt find answer.
Tested on a different environment 3.6 Mongo and the index ops increased by 1.

The environments are not the same so I will try to reproduce it on the exact same environment.
Thanks

Hi @Gal_Itach,

Can you confirm the exact version of MongoDB server and Compass used in your original test?

It sounds like your later test returns the expected outcome.

Regards,
Stennie