Database Reference
In-Depth Information
Utilizing the profiling feature
We already used the profiling feature in Chapter 8 , Analyzing and Improving Database
Performance to check a database and improve the performance of a database. As profiling
is one of the diagnosing methods, we will take a quick look at this feature again in this
chapter.
Profiling is a technique to detect slow operations. Thus, through it you can find inefficient
operations and improve performance by altering operations and queries.
To enable profiling for a MongoDB instance, you can use following function:
db.setProfilingLevel(level, slowms)
The following table shows the parameters of the setProfilingLevel function:
Parameter
Description
level
This refers to verbosity level of profiling.
slowms This is optional. It is used to define the slow operations threshold in milliseconds.
The following command is a sample of issuing the preceding function in the mongo inter-
active shell:
db.setProfilingLevel(1, 1000)
So, the preceding command enables profiling for the MongoDB instance with level 1 and
threshold 1000 milliseconds.
The output of this command in the mongo shell is same as the following screenshot:
The MongoDB engine supports three main levels of profiling. The following table shows
the three different levels of profiling:
Search WWH ::




Custom Search