elixir-mongo / mongodb

MongoDB driver for Elixir
Apache License 2.0
571 stars 156 forks source link

Using explain to analyse the query before executing. #323

Closed vik228 closed 4 years ago

vik228 commented 4 years ago

Hey, How can i use explain to analyse my queries before executing?

ankhers commented 4 years ago

This driver does not currently have a dedicated function for this. However, you can use the explain command.

Mongo.command(pid, %{ 
  explain: %{ 
    count: "products", 
    query: %{ quantity: %{ "$gt": 50 } } },
  verbosity: "queryPlanner"
  }
)

If you would like to contribute a dedicated function for this, I would gladly merge it.

ankhers commented 4 years ago

I am going to close this. If you have any other questions related to this, please feel free to re-open.