How do you use explain with aggregate and cluster?

Viewed 1187

I have a mongodb sandbox with mongodb atlas and am querying using the native nodejs driver (not mongoose). When i run a aggregate query and use explain, i get the following error "explain" cannot be used on an aggregate call with readConcern/writeConcern.

I tried setting my connection uri with w=0 but that didn't help. I didn't see anything in the docs for options in new MongoClient(uri, options);

I'm trying to measure query performance. How do you use explain with aggregate and cluster?

1 Answers

For me, removing write concern option "w" altogether did the trick. Using nodejs driver 3.6. Things to check:

  • Remove "w" and "readConcern" from options
  • Remove "w" and "readConcern" from URI
Related