0

I am comparing against MySQL, where we fire a query the first attempt might read from disk and the second read will be from Memory. Does this happens in MongoDB? The reason is I am having a Query with AND & OR query and I have index on all fields. If I remove one of the OR FIELD , the read is confined to Index only (KeyExamined) and if I add the same field it's reading from Disk as well (Documents Examined).

I was in the impression the first time the documents would be read from disk and second time it would read from memory. Please let me know

Musthafa

Musthafa
  • 13
  • 3

1 Answers1

0

"Documents examined" is not the same as "reading from disk". All databases have some way of storing data in memory for caching purposes, MongoDB included. Similarly the index doesn't need to be loaded in memory completely or at all.

If your query is not satisfiable using the index only, you need to rewrite it or reindex the database.

D. SM
  • 13,584
  • 3
  • 12
  • 21