db.setProfilingLevel difference between 0 and 1

Good Day ,

What is the exact difference between profiling level 0 and 1

As per document , when profile level is 0 it says “The profiler is off and does not collect any data. This is the default profiler level.”

But in lab when i set “db.setProfilingLevel(0,{slowms:0})” and triggered a slow run query it got recorded in mongod.log

SO if level 0 doesnt collect data why it stored such data in logs ?

or am i misunderstanding any , kindly advise

FROM THE DOC <<<<<

0–>The profiler is off and does not collect any data. This is the default profiler level.

1—>

The profiler collects data for operations that exceed the slowms threshold or match a specified filter.

When a filter is set:

  • The slowms and sampleRate options are not used for profiling.
  • The profiler only captures operations that match the filter.

Hello @sadham_hussain

The difference is that with level 0 the slow queries are only printed to the log. With level 1 the slow queries are printed to the log AND also added to the system.profile collection of the database where profiling is enabled.

With the parameter value (0,1,2) collection of data refers to the profiler storing it in the collection, not logging it.

2 Likes

Thanks much for the explanation , I will research further to understand more

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.