Database Reference
In-Depth Information
Utilizing profiling
Writing an optimized query is one of the most significant factors to maximize performance
in a database engine. When you are faced with performance issues, there is a method to
find and fix the corresponding part or query. Profiling the database and queries is a method
known to programmers to find bottlenecks and fix performance problems.
The good news is that MongoDB supports profiling for each instance or for each database.
Using this feature, you can find the slowest queries in the program and address the issues
by replacing the old queries with optimized versions.
MongoDB has a profiler engine that collects corresponding data for read/write operations,
cursors, and database commands on a mongod process. The profiler engine is configurable
for an instance or a database. Moreover, identical to all profiling methods, the profiler level
is also configurable in three different levels. Each level is designed for a specific approach
and the profiler engine works differently on each level.
After enabling and configuring the profiler engine, the MongoDB profiler engine collects
all data in the system.profile collection. This collection contains documents that rep-
resent the profiler engine's output. The profiler engine supports different levels of profiling,
so you can configure it to be correct based on your usage.
The following list shows the different levels of profiling available in MongoDB:
Level 0 : This means the profiler engine is turned off.
The profiler engine won't log anything in this level. This is the default level for the
profiler.
Level 1 : The profiler collects data under certain conditions.
For instance, the profiler collects data for slow operations. By default, the profiler
logs the queries slower than 100 milliseconds. However, you can change this set-
ting using the slowOpThresholdMs option.
Level 2 : This means that the profiler engine collects data about all the operations
in a database.
The profiler engine uses the operationProfiling.slowOpThresholdMs option
to consider an operation as a slow operation. The default value for this option is 100 ms,
Search WWH ::




Custom Search