Index statistic zeroing

Hi.

After monitoring long queries I created index and the index statistic counter started to increase from 0 to 15, than stopped. I realized also that after reboot/restart all the index statistic counters zeroing and some of it stay zeroed despite of queries. Deleting the particular index with zero counter causing slowness, recreating obviously fix the slowness.
So the question is-why in some cases index usage statistic counter stop without obvious reason?

Hi @SeventhSon,

After monitoring long queries I created index and the index statistic counter started to increase from 0 to 15, than stopped.

Would you be able to advise how you are checking the index statistics? I assume it would be through the $indexStats aggregation stage but please correct me if I am incorrect in my assumption here.

I realized also that after reboot/restart all the index statistic counters zeroing and some of it stay zeroed despite of queries.

Upon mongod restarts, the index statistics are refreshed (The "accessess.since" value is the time from when the mongod begins recording the index stats). However, the behaviour regarding the counter staying at zero does sound odd (assuming that the index is being used by said queries)

So the question is-why in some cases index usage statistic counter stop without obvious reason?

One example I can think of is if you’re running the query which uses an index with the explain output. I.e. db.collection.find().explain() won’t increment the counter. However, would you be able to provide the following information so that I can try reproduce the behaviour you’ve mentioned regarding the index counter not increasing:

  1. MongoDB version in use
  2. The index created
  3. The associated queries that should be using the index
  4. 3-4 sample document(s) that are returned by the queries
  5. executionStats explain output for the suspected query not raising the counter

Regards,
Jason

1 Like