Using profiler to profile operations
In this recipe, we will look at mongo's inbuilt profiler that would be used to profile the operations executed on the mongo server. It is a utility that is used to log all or slow operations that could be used for analysis of the performance of the server.
Getting ready
In this recipe, we will perform some operations on a standalone mongo instance and profile them. We need to start a standalone server listening to any port for client connections; in this case, we will stick to the default 27017
. If you are not aware how to start a standalone server, refer to Installing single node MongoDB in Chapter 1, Installing and Starting the Server. We also need to start a shell that would be used to perform querying, enabling profiling, and viewing the profiling operation.
How to do it…
Once the server is started and the shell is connected to it, execute the following to get the current profiling level:
> db.getProfilingLevel()
The default level should be
0
(no profiling...