[SERVER-5288] use no more precision than necessary when reporting explain output Created: 12/Mar/12  Updated: 11/Jul/16  Resolved: 23/Mar/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.1.1
Fix Version/s: 2.1.1

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Can we go back to displaying longs as just numbers in the output? Are there other commands whose output is similarly affected?

> db.x1.find().explain()
{
	"cursor" : "BasicCursor",
	"isMultiKey" : false,
	"n" : NumberLong(1),
	"nscannedObjects" : NumberLong(1),
	"nscanned" : NumberLong(1),
	"scanAndOrder" : false,
	"indexOnly" : false,
	"nYields" : 0,
	"nChunkSkips" : NumberLong(0),
	"millis" : 0,
	"indexBounds" : {
		
	},
	"server" : "lazarus:27017"
}



 Comments   
Comment by auto [ 23/Mar/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-5288 Use appendNumber when writing long longs to explain output.
Branch: master
https://github.com/mongodb/mongo/commit/44c4a5d8d122881c91db3ce06498b89f76877035

Comment by Eliot Horowitz (Inactive) [ 12/Mar/12 ]

You should use appendNumber() instead of append()

Comment by Aaron Staple [ 12/Mar/12 ]

And it looks like the old explain was doing this for the values it was recording as long longs. I guess I'll fix by doing the same.

Comment by Aaron Staple [ 12/Mar/12 ]

It looks like what I described above is what we do for stats() though.

Comment by Aaron Staple [ 12/Mar/12 ]

The reason for this is that I changed the variables for recording certain values to long long from int, since in some cases we can potentially get counts that cannot be represented as ints. We could fix by only returning explain output using a bson long when a bson long is necessary to properly represent a value. But if this is primarily a shell ui issue that might not be an ideal fix.

Comment by Eric Milkie [ 12/Mar/12 ]

The numbers shown as NumberLong() above are actually 64-bit long longs. There might be a way to construct the BSON such that when displayed, the long longs look like regular numbers.

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