summaryrefslogtreecommitdiff
path: root/src/mongo/shell/collection.js
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-01-14 18:01:01 -0500
committerBenety Goh <benety@mongodb.com>2015-01-15 12:03:15 -0500
commitf0680bcb8478cf77682d3d202d123fc2be8cbef9 (patch)
tree847eb3a8863a17bbdea29c7edafe1f2b9e489995 /src/mongo/shell/collection.js
parent5ccc23d04e2662616c993d607a80666d021e1e5d (diff)
downloadmongo-f0680bcb8478cf77682d3d202d123fc2be8cbef9.tar.gz
SERVER-16848 fixed db.collections.totalSize() so that it uses totalIndexSize from collection stats instead of iterating though index namespaces.
Diffstat (limited to 'src/mongo/shell/collection.js')
-rw-r--r--src/mongo/shell/collection.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js
index c0033a3dbce..fb4d48f6e56 100644
--- a/src/mongo/shell/collection.js
+++ b/src/mongo/shell/collection.js
@@ -1169,16 +1169,10 @@ DBCollection.prototype.totalIndexSize = function( verbose ){
DBCollection.prototype.totalSize = function(){
var total = this.storageSize();
- var mydb = this._db;
- var shortName = this._shortName;
- this.getIndexes().forEach(
- function( spec ){
- var coll = mydb.getCollection( shortName + ".$" + spec.name );
- var mysize = coll.storageSize();
- //print( coll + "\t" + mysize + "\t" + tojson( coll.validate() ) );
- total += coll.dataSize();
- }
- );
+ var totalIndexSize = this.totalIndexSize();
+ if (totalIndexSize) {
+ total += totalIndexSize;
+ }
return total;
}