Chapter 1 - Profiling the Database - Setting slowms to 0

Hi all,

The lecture contains the below syntax to set slowms:

mongo newDB --host 192.168.103.100:27000 -u m103-admin -p m103-pass --authenticationDatabase admin --eval '
db.setProfilingLevel( 1, { slowms: 0 } )
'

Using MongoDB shell version v3.4.18 on Linux this did not work for me, but the below did:

db.setProfilingLevel( 1, 0 )

See below that ‘was’ was showing ‘100’ until I changed it by using the syntax above:

MongoDB Enterprise > db.setProfilingLevel( 2, { slowms: 0 } )
{ "was" : 1, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }

MongoDB Enterprise > db.setProfilingLevel( 1, { slowms: 0 } )
{ "was" : 2, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }

MongoDB Enterprise > db.setProfilingLevel( 1, 0 )
{ "was" : 1, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }

MongoDB Enterprise > db.setProfilingLevel( 1, 0 )
{ "was" : 1, "slowms" : 0, "sampleRate" : 1, "ok" : 1 }

I guess the syntax changed?

Regards,
Laszlo

1 Like

Hi @Laszlo_93142,

Yes, you are right. The syntax has changed since 3.4 version. I would recommend using the latest version of mongod.

And, you can also check the profilingStatus by running db.getProfilingStatus().

This is in version 3.4.19:

  MongoDB Enterprise > db.getProfilingStatus()
  { "was" : 1, "slowms" : 0 }

This is with version 4.0.x:

MongoDB Enterprise > db.getProfilingStatus()
{ "was" : 2, "slowms" : 0, "sampleRate" : 1 } 

Kanika

1 Like