[SERVER-17365] Add formatting for sizes in shell output Created: 24/Feb/15  Updated: 26/Oct/21  Resolved: 26/Oct/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.0.0-rc9
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Richard Penner Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Quick: how big is 13272542304? I couldn't tell you myself, without lining up my mouse cursor on the right side of the 4, and counting in groups of 3.
Some simple comma formatting would go a long way: 13,272,542,304.



 Comments   
Comment by Richard Penner [ 24/Feb/15 ]

That's a decent option, but I'd like to challenge your assumption that people want to copy and paste collection sizes in the shell. If I type in

db.stats(1024)

and see 4696016, it's just moderately easier to read than 4808738848; I'm still using the mouse cursor to figure out the size, and it's still too large to read. And let's not pretend anyone will bother typing db.stats(1048576) to see it in MBs.

If you're afraid of breaking output compatibility, why not add a server setting called HumanReadableOutput and have it off by default?

Comment by Ramon Fernandez Marina [ 24/Feb/15 ]

Thanks for the additional information richardpenner. While having db.serverStatus() print numbers like

"totalTime" : NumberLong("511,032,539,000"),

instead of

"totalTime" : NumberLong("511032539000"),

may be helpful in some cases, it would remove the ability to cut & paste those numbers for use in the shell. Note however that some commands like db.stats() and db.collection.stats() take an optional scale parameter that comes in handy:

Optional. The scale used in the output to display the sizes of items. By default, output displays sizes in bytes. To display kilobytes rather than bytes, specify a scale value of 1024.

Can you give this a try and see if it meets your needs?

Comment by Richard Penner [ 24/Feb/15 ]

Seen in db.serverStats() and db.mydatabase.stats() for example.

Comment by Ramon Fernandez Marina [ 24/Feb/15 ]

richardpenner, can you please provide some more info on how are you getting that number? Is it from db.stats() for example?

Thanks,
Ramón.

Generated at Thu Feb 08 03:44:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.