How can I see executed the raw query? #1230
Replies: 3 comments
-
|
Hey, I just wanted to ping again for this question, thanks in advance :) |
Beta Was this translation helpful? Give feedback.
-
|
I think you can do |
Beta Was this translation helpful? Give feedback.
-
|
While the library you are using (likely Motor/Pymongo based) often doesn't expose a direct .get_raw_query() method like an ORM might, you can achieve your goal by leveraging MongoDB's native logging/profiling tools or by utilizing the explain() method during development. The explain() method allows you to see the execution plan, which effectively contains the raw query structure (filter, sort, skip, limit) and execution statistics for debugging performance issues, as demonstrated by running await query.explain(). If you need constant logging of all executed queries, you must enable Database Profiling directly on your MongoDB server instance. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team ✋ thanks for this great library, we love it.
We want to know is there any way to see the executed (or will be executed) raw mongo queries?
Let's say I have the above code block, is there sth like
query.get_raw_query()?Expected output:
{ "filter": {"search_key": "search_value"}, "sort": [{"create_at", 1}], "skip": 0, "limit": 10 }or
I need that to debug executed queries, aggregations when I face query related performance issues. That would great if I hands-on try on the executed query on db.
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions