Peter Morlion logo


See MongoDB’s Last Queries With the Profiler

I’ve searched for this several times over the last year or two, and each time it takes me a while to find the solution. If you’re looking for the last queries that were executed against your MongoDB instance, these are the steps you need to perform:

Enable The Profiler

First, enable the profiler by executing the following command:


Keep in mind that this has an impact on performance. Best not to do this on the production database.

If you want to know what the original value was first, you can see it in the output of the above command or just run this command first:


Check The Queries

Now you can see the last commands that MongoDB received by running:


Clean Up

Don’t forget to set the profiling level back to 0:


Leave a Reply

Your email address will not be published. Required fields are marked *