1

I have a query that fetches 10k documents and every document has a dbref to another document. This query takes ~5 seconds to run and is unacceptable. During debug and logging i've spotted that mongo driver makes a round trip to database for every DbRef.

My DbRef documents are the same for the most part of primary documents. I would like to use a cache for this and don't make additional round trips to mongo for every document.

The question is : could DbRefs be cached while executing primary query?

aleshka-batman
  • 187
  • 1
  • 13
  • How did you show Dbref round trips in logs? I have been looking for a way to do this for quite some time – jemag May 08 '19 at 18:23
  • @jemag try to set org.mongodb logging level to debug. – aleshka-batman May 09 '19 at 08:06
  • Actually just finally found it yesterday. It was not implemented before but now it is : https://github.com/spring-projects/spring-data-mongodb/pull/659 . I can see DBRef fetching/resolution by using the given library version and trace logging : "logging.level.org.springframework.data.mongodb=trace" – jemag May 09 '19 at 14:10
  • same problem here – Jordi Martí Mar 17 '21 at 03:22

0 Answers0