[SERVER-17715] Inconsistent reporting of "storageSize" between mmapv1 and wired tiger Created: 24/Mar/15  Updated: 25/Mar/15  Resolved: 25/Mar/15

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 3.0.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Steve Briskin (Inactive) Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

On MMAPv1, db.stats().storageSize includes both data and indexes. On WiredTiger it only includes data. It would be clearer if "storageSize" was defined more consistently across the storage engines.



 Comments   
Comment by Bruce Lucas (Inactive) [ 25/Mar/15 ]

Just for the information of anyone who might see this, that test isn't really measuring the storage size for WT: the storage size isn't known until the collection is actually written to disk, and that doesn't happen until it is checkpointed. Adding db.adminCommand({fsync:1}) before the calls to db.stats() to force a checkpoint gives much different numbers for WT:

Before creating the index {a: 1}
{ "storageSize" : 28672, "indexes" : 1, "indexSize" : 20480 }
After creating the index {a: 1}
{ "storageSize" : 28672, "indexes" : 2, "indexSize" : 45056 }

The conclusion is still correct however: both WT and mmapv1 include only the collection data in storageSize.

The behavior that the storageSize is not computed immediately for WT is an inconsistency between WT and mmapv1, but it is unavoidable due to the difference between the two in how and when data is written to disk.

Comment by Steve Briskin (Inactive) [ 25/Mar/15 ]

Max, you're absolutely right. My understanding of what was included in "storageSize" on mmapv1 was wrong. Works as designed.

Comment by Max Hirschhorn [ 24/Mar/15 ]

Hi Steve,

I'm seeing that db.stats().storageSize remains the same after an index is added to a collection. Is there a case where you observed something different happening?

(function() {
    "use strict";
 
    function extractRelevantStats(stats) {
        return {
            storageSize: stats.storageSize,
            indexes: stats.indexes,
            indexSize: stats.indexSize,
        };
    }
 
    var collName = 'storage_size_test';
    var t = db[collName];
 
    t.drop();
    for (var i = 0; i < 1000; ++i) {
        t.insert({_id: ObjectId(), a: i});
    }
 
    print('Before creating the index {a: 1}');
    printjson(extractRelevantStats(db.stats()));
 
    t.ensureIndex({a: 1});
 
    print('After creating the index {a: 1}');
    printjson(extractRelevantStats(db.stats()));
})();

With MMAPv1,

Before creating the index {a: 1}
{ "storageSize" : 184320, "indexes" : 1, "indexSize" : 40880 }
After creating the index {a: 1}
{ "storageSize" : 184320, "indexes" : 2, "indexSize" : 81760 }

With WiredTiger,

Before creating the index {a: 1}
{ "storageSize" : 4096, "indexes" : 1, "indexSize" : 4096 }
After creating the index {a: 1}
{ "storageSize" : 4096, "indexes" : 2, "indexSize" : 28672 }

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