[SERVER-16917] Return fileSize to db.stats() when using wiredTiger Created: 17/Jan/15  Updated: 13/Dec/19  Resolved: 28/Jun/19

Status: Closed
Project: Core Server
Component/s: Admin, Storage
Affects Version/s: 2.8.0-rc5
Fix Version/s: 4.3.1

Type: Improvement Priority: Minor - P4
Reporter: Chad Kreimendahl Assignee: Maria van Keulen
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 DRIVERS-729 Return fileSize to db.stats() when us... Closed
Documented
is documented by DOCS-12911 Investigate changes in SERVER-16917: ... Closed
Duplicate
is duplicated by SERVER-16271 Suppress mmapv1 specific stats from d... Closed
Related
is related to DOCS-13298 State explicitly that sizeOnDisk alre... Closed
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2019-07-01
Participants:

 Description   

Some properties in db.stats() when using mmap do not exist when querying with wiredTiger configured. However, where a similar stat does exist, it should be included. In this case, the most obvious missing stat is fileSize.

In WiredTiger this is the same as storage size plus index size.



 Comments   
Comment by Githook User [ 22/Nov/19 ]

Author:

{'name': 'David Storch', 'username': 'dstorch', 'email': 'david.storch@mongodb.com'}

Message: SERVER-44793 Add 'requires_fcv_44' tag to apitest_dbcollection.js

This tests the "totalSize" field of the collStats command,
which was added in 4.3.1 by SERVER-16917.
Branch: master
https://github.com/mongodb/mongo/commit/728aaa3ee1d1f19491be219e20c18c806db4ca68

Comment by Githook User [ 28/Jun/19 ]

Author:

{'name': 'Maria van Keulen', 'email': 'maria@mongodb.com', 'username': 'mvankeulen94'}

Message: SERVER-16917 Add totalSize field to dbStats and collStats

This commit also removes the now obsolete numExtents field.
Branch: master
https://github.com/mongodb/mongo/commit/47ee8f8cde1d1e116caf223458c15b4af10943d6

Comment by Eric Sedor [ 30/Jun/16 ]

In my testing, db.stats().storageSize + db.stats().indexSize is indeed identical to sizeOnDisk in listDatabases. Is there any reason these would ever differ?

Comment by Chad Kreimendahl [ 21/Jan/15 ]

Matt,

For us it was primarily about tracking data usage for our customers. We could likely get by with a combination of dataSize or storageSize plus indexSize. It actually looks like we get the precise number of sizeOnDisk (at least for wt) between storageSize + indexSize.

Comment by Matt Kangas [ 21/Jan/15 ]

Database size is cheap to compute for mmapv1, but for WiredTiger or any other KVEngine it will be more costly (stat many files, where "many" is nCollections+nIndices).

Note that db.stats() is the "dbstats" command under the hood, and db.getMongo().getDBs() is the "listDatabases" command.

Perhaps the key question is: what depends on the "dbstats" command other than humans and how frequently is it called in practice? I'm thinking about things like the MMS agent.

Comment by Asya Kamsky [ 17/Jan/15 ]

I realize it's not part of db.stats() but you can see the info via command:

db.getMongo().getDBs()
{
	"databases" : [
		{
			"name" : "local",
			"sizeOnDisk" : 32768,
			"empty" : false
		},
		{
			"name" : "sbtest",
			"sizeOnDisk" : 7081512960,
			"empty" : false
		}
	],
	"totalSize" : 7081545728,
	"ok" : 1
}

This is where "show dbs" helper in the shell gets its sizes and I checked, this corresponds exactly to on-disk size of the directory.

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