[SERVER-1507] option in shell to print how long each command takes and certain stats Created: 28/Jul/10  Updated: 12/Jul/16  Resolved: 27/Sep/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: 2.1.0

Type: Improvement Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Antoine Girbal
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-1586 verbose shell command results option Closed
Duplicate
is duplicated by SERVER-1586 verbose shell command results option Closed
Related
related to DOCS-5246 Add documentation for setVerboseShell() Closed
Participants:

 Comments   
Comment by auto [ 05/Oct/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: - SERVER-1507: option as string must be converted to boolean

Comment by Antoine Girbal [ 26/Sep/11 ]

output for find is displayed in the cursor iteration loop, like:

..

{ "_id" : ObjectId("4de8f6b3ceadffd21635ba45"), "userId" : 0, "text" : "blahblah", "votes" : 8 } { "_id" : ObjectId("4de8f6b3ceadffd21635ba47"), "userId" : 13, "text" : "blahblah", "votes" : 11 } { "_id" : ObjectId("4de8f6b3ceadffd21635ba49"), "userId" : 36, "text" : "blahblah", "votes" : 12 }

Fetched 20 record(s) in 8ms
Cursor has more records

Comment by auto [ 26/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1507: added verbose output to find
Branch: master
https://github.com/mongodb/mongo/commit/5238cccca6ce47f9b427ace48cd57a4fa225ba74

Comment by Antoine Girbal [ 26/Sep/11 ]

Added a method to do:
set verbose [true|false]

But I kept a regular method for it because this syntax cannot get called from a script and we cant test it.

Comment by auto [ 26/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1507: add shell syntax
Branch: master
https://github.com/mongodb/mongo/commit/8acb9cdcd1799a65817d6872f07b647cfddf9497

Comment by Eliot Horowitz (Inactive) [ 22/Sep/11 ]

Should also show time for queries.

Not sure about name.

Also maybe shouldn't be a function, but follow shell model.

set verbose true
set verbose false

Comment by auto [ 21/Sep/11 ]

Author:

{u'login': u'kchodorow', u'name': u'Kristina', u'email': u'kristina@10gen.com'}

Message: fix SERVER-1507 js that broke all buildbots
Branch: master
https://github.com/mongodb/mongo/commit/5282745c1670ac8b7e2aff47174f251d90c159e1

Comment by auto [ 21/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1401: Dont call getLastError if last statement didn't go to server
SERVER-1507: improve output. Also display for inserts.
Branch: master
https://github.com/mongodb/mongo/commit/61d496c3dd7940565d6299980a1ce0a3ee913a0e

Comment by auto [ 20/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1507: test
Branch: master
https://github.com/mongodb/mongo/commit/1329db4856468f2546a03f8947351f636512ef8b

Comment by Antoine Girbal [ 20/Sep/11 ]

Moved at shell level:

PRIMARY> setVerboseShell()
PRIMARY> db.test.update(

{a:1}

,

{b:1}

)
Modified 1 existing record(s) in 1ms
PRIMARY> setVerboseShell(false)
PRIMARY> db.test.update(

{a:1}

,

{b:1}

)
PRIMARY> setVerboseShell(true)
PRIMARY> db.test.update(

{a:1}

,

{b:1}

)
Modified 0 record(s) in 1ms

Comment by auto [ 20/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1507: moved option at shell level
Branch: master
https://github.com/mongodb/mongo/commit/30e2b968998300857bb61c62a31814facd5fa226

Comment by Eliot Horowitz (Inactive) [ 20/Sep/11 ]

new Mongo( "foo.com" )
connect( "foo.com/blah" )

not a command line option.
maybe just
> setVerboseShell()

Comment by Antoine Girbal [ 20/Sep/11 ]

right now the option is at the "mongo" level.
I thought this was rather global, how do you create multiple mongos in a shell?
Otherwise I could make it a cmd line option instead.

Comment by Eliot Horowitz (Inactive) [ 20/Sep/11 ]

Not sure this is implemented the right way.

This way from what I can tell, if I open 2 Mongo connections, its only set on one of them.

Should probably be a shell level setting, not a connection level.

Comment by Antoine Girbal [ 20/Sep/11 ]

in theory it should also work for inserts, but "n" is always 0 in the lastError.
PRIMARY> db.test.insert(

{a: 1}

)
PRIMARY> db.getLastErrorCmd()
{
"n" : 0,
"lastOp" :

{ "t" : 1316553344000, "i" : 1 }

,
"connectionId" : 19,
"err" : null,
"ok" : 1
}

Comment by Antoine Girbal [ 20/Sep/11 ]

This option is called verboseShell, it is available as a command.
PRIMARY> db.setVerboseShell()
PRIMARY> db.test.remove(

{a:1}

)
Modified 2 record(s) in 1ms
PRIMARY> db.test.update(

{a:1}

,

{b:1}

)
Modified 0 record(s) in 1ms
PRIMARY> db.test.insert(

{a: 1}

)
PRIMARY> db.test.update(

{a:1}

,

{b:1}

)
Modified 1 existing record(s) in 1ms

Comment by auto [ 20/Sep/11 ]

Author:

{u'login': u'agirbal', u'name': u'agirbal', u'email': u'antoine@10gen.com'}

Message: SERVER-1507: option in shell to print how long each command takes and certain stats
Branch: master
https://github.com/mongodb/mongo/commit/0c8d421606e22bc6eed3b9cb149db8688b26ab5f

Comment by Eliot Horowitz (Inactive) [ 20/Sep/11 ]

For now - we should make it an option.
If after 2.2 it seems like most people want it on, we can reconsider.

Comment by Antoine Girbal [ 19/Sep/11 ]

also this would avoid calling getLastError whenever an operation does not return a result in the shell.
This would fix SERVER-1401

Comment by Antoine Girbal [ 19/Sep/11 ]

Most likely this feature doesnt make sense for find() type of operations, since the result is handled by a cursor.
For timing operation one can use explain().
Same thing for commands, which usually return a result that includes timing info.

So planning to implement this for "write" type of commands like update, remove which currently print nothing.
It would be very useful for admins since everyone wants to see how many records just got touched, or if they just removed all their records by accident..

PRIMARY> db.getMongo().setExtraInfo()
PRIMARY> db.comments.update(

{o: "blah"}

,

{a: 0}

)
Modified 0 record(s) in 7ms
PRIMARY> db.comments.remove(

{o: "blah"}

)
Modified 0 record(s) in 11ms
PRIMARY> db.col.remove({_id: "a"})
Modified 1 record(s) in 44ms
PRIMARY> db.col.remove({_id: "a"})
Modified 0 record(s) in 1ms

I feel that the info is non intrusive and necessary for admin.
Also it seems to only apply to update/remove for now.
So I would argue to not add a new option for it, and just make this output the default.
Also then the text can be more tailored and user friendly.

Generated at Thu Feb 08 02:57:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.