MongoDB through the JavaScript shell

How to Using CRUD operation in the MongoDB shell

How to Building indexes and using explain()

How to understand basic administration

How to getting help

CRUD: create,read,update,delete

Let's start by switch to the tutorial database:

> use tutorial
switched to db tutorial

Insert and queries:

> db.users.insert({username: "smith"})
WriteResult({ "nInserted" : 1 })
> db.users.find()
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }

> db.users.insert({username: "jones"})
WriteResult({ "nInserted" : 1 })
> db.users.count()
2

_id value as the document's primary key.

Pass a QUERY PREDICATE

> db.users.find()
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
{ "_id" : ObjectId("623d4a1ecc79fab4146f173f"), "username" : "jones" }
> db.users.find({username: "jones"})
{ "_id" : ObjectId("623d4a1ecc79fab4146f173f"), "username" : "jones" }
> db.users.find({_id : ObjectId("623d49d3cc79fab4146f173e"), username: "smith"})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
>
> db.users.find({$and: [{_id : ObjectId("623d49d3cc79fab4146f173e")},{username: "smith"}]})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
> db.users.find({$or: [{username: "smith"},{username: "jones"}]})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
{ "_id" : ObjectId("623d4a1ecc79fab4146f173f"), "username" : "jones" }

Updating documents

> db.users.find({username: "smith"})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
> db.users.update({username:"smith"},{$set: {country: "Canada"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.users.find().pretty()
{
        "_id" : ObjectId("623d49d3cc79fab4146f173e"),
        "username" : "smith",
        "country" : "Canada"
}

Operator update

> db.users.find({username: "smith"})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith" }
> db.users.update({username:"smith"},{$set: {country: "Canada"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.users.find().pretty()
{
        "_id" : ObjectId("623d49d3cc79fab4146f173e"),
        "username" : "smith",
        "country" : "Canada"
}

Updating complex Data

> db.users.find({username: "smith"})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith", "favorites" : { "cities" : [ "Chicago", "Cheyenne" ], "movies" : [ "Casablanca", "For a Few Dollars More", "The String" ] } }
> db.users.update({username: "jones"},
... {
...   $set: {
...     favorite: {
...       movies: ["Casablanca","Rocky"]
...     }
...   }
... })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
>
> db.users.find().pretty()
{
        "_id" : ObjectId("623d49d3cc79fab4146f173e"),
        "username" : "smith",
        "favorites" : {
                "cities" : [
                        "Chicago",
                        "Cheyenne"
                ],
                "movies" : [
                        "Casablanca",
                        "For a Few Dollars More",
                        "The String"
                ]
        }
}
{
        "_id" : ObjectId("623d4a1ecc79fab4146f173f"),
        "username" : "jones",
        "favorite" : {
                "movies" : [
                        "Casablanca",
                        "Rocky"
                ]
        }
}
>

> db.users.find({"favorites.movies": "Casablanca"})
{ "_id" : ObjectId("623d49d3cc79fab4146f173e"), "username" : "smith", "favorites" : { "cities" : [ "Chicago", "Cheyenne" ], "movies" : [ "Casablanca", "For a Few Dollars More", "The String" ] } }
>

More Advanced UPDATES

>
> db.users.update({"favorite.movies": "Casablanca"},
...     {$addToSet: {"favorite.movies": "The Maltese Falcon"}},
...           false,
...           true )

WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.users.find({"favorites.movies": "Casablanca"}).pretty()
{
        "_id" : ObjectId("623d49d3cc79fab4146f173e"),
        "username" : "smith",
        "favorites" : {
                "cities" : [
                        "Chicago",
                        "Cheyenne"
                ],
                "movies" : [
                        "Casablanca",
                        "For a Few Dollars More",
                        "The String"
                ]
        }
}
>

Deleting data

if given no parameters , a remove operation will clear a collection of all its documents.

> db.foo.remove()

Note that the remove() operation doesn't actually delete the collection;it merely removes documents from a collection.You can think of it as being analogous to SQL's DELETE command.

If your intent is to delete the collection along with all of its indexes,use the drop() method.

>
> db.users.drop()
true
> db.users.find().pretty()
>
 


Other shell features

> db.help()
DB methods:
        db.adminCommand(nameOrDocument) - switches to 'admin' db, and runs command [just calls db.runCommand(...)]
        db.aggregate([pipeline], {options}) - performs a collectionless aggregation on this database; returns a cursor
        db.auth(username, password)
        db.commandHelp(name) returns the help for the command
        db.createUser(userDocument)
        db.createView(name, viewOn, [{$operator: {...}}, ...], {viewOptions})
        db.currentOp() displays currently executing operations in the db
        db.dropDatabase(writeConcern)
        db.dropUser(username)
        db.eval() - deprecated
        db.fsyncLock() flush data to disk and lock server for backups
        db.fsyncUnlock() unlocks server following a db.fsyncLock()
        db.getCollection(cname) same as db['cname'] or db.cname
        db.getCollectionInfos([filter]) - returns a list that contains the names and options of the db's collections
        db.getCollectionNames()
        db.getLastError() - just returns the err msg string
        db.getLastErrorObj() - return full status object
        db.getLogComponents()
        db.getMongo() get the server connection object
        db.getMongo().setSecondaryOk() allow queries on a replication secondary server
        db.getName()
        db.getProfilingLevel() - deprecated
        db.getProfilingStatus() - returns if profiling is on and slow threshold
        db.getReplicationInfo()
        db.getSiblingDB(name) get the db at the same server as this one
        db.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if set
        db.hostInfo() get details about the server's host
        db.isMaster() check replica primary status
        db.hello() check replica primary status
        db.killOp(opid) kills the current operation in the db
        db.listCommands() lists all the db commands
        db.loadServerScripts() loads all the scripts in db.system.js
        db.logout()
        db.printCollectionStats()
        db.printReplicationInfo()
        db.printShardingStatus()
        db.printSecondaryReplicationInfo()
        db.rotateCertificates(message) - rotates certificates, CRLs, and CA files and logs an optional message
        db.runCommand(cmdObj) run a database command.  if cmdObj is a string, turns it into {cmdObj: 1}
        db.serverStatus()
        db.setLogLevel(level,<component>)
        db.setProfilingLevel(level,slowms) 0=off 1=slow 2=all
        db.setVerboseShell(flag) display extra information in shell output
        db.setWriteConcern(<write concern doc>) - sets the write concern for writes to the db
        db.shutdownServer()
        db.stats()
        db.unsetWriteConcern(<write concern doc>) - unsets the write concern for writes to the db
        db.version() current version of the server
        db.watch() - opens a change stream cursor for a database to report on all  changes to its non-system collections.
>

How to creating and querying with indexes

It's common to create indexes to enhance query performance.

Creating a large collection

>
> for (i = 0; i < 20000; i++) {
... db.numbers.save({num: i});
... }

WriteResult({ "nInserted" : 1 })
>
> db.numbers.count()
20000
> db.numbers.find()
{ "_id" : ObjectId("623d669b7f64c5090cc0af9a"), "num" : 0 }
{ "_id" : ObjectId("623d669b7f64c5090cc0af9b"), "num" : 1 }
{ "_id" : ObjectId("623d669b7f64c5090cc0af9c"), "num" : 2 }
{ "_id" : ObjectId("623d669b7f64c5090cc0af9d"), "num" : 3 }
{ "_id" : ObjectId("623d669b7f64c5090cc0af9e"), "num" : 4 }
{ "_id" : ObjectId("623d669b7f64c5090cc0af9f"), "num" : 5 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa0"), "num" : 6 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa1"), "num" : 7 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa2"), "num" : 8 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa3"), "num" : 9 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa4"), "num" : 10 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa5"), "num" : 11 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa6"), "num" : 12 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa7"), "num" : 13 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa8"), "num" : 14 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afa9"), "num" : 15 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afaa"), "num" : 16 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afab"), "num" : 17 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afac"), "num" : 18 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afad"), "num" : 19 }
Type "it" for more
> it
{ "_id" : ObjectId("623d669b7f64c5090cc0afae"), "num" : 20 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afaf"), "num" : 21 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb0"), "num" : 22 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb1"), "num" : 23 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb2"), "num" : 24 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb3"), "num" : 25 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb4"), "num" : 26 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb5"), "num" : 27 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb6"), "num" : 28 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb7"), "num" : 29 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb8"), "num" : 30 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb9"), "num" : 31 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afba"), "num" : 32 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afbb"), "num" : 33 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afbc"), "num" : 34 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afbd"), "num" : 35 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afbe"), "num" : 36 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afbf"), "num" : 37 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afc0"), "num" : 38 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afc1"), "num" : 39 }
Type "it" for more
>
> db.numbers.find({num: 500})
{ "_id" : ObjectId("623d669c7f64c5090cc0b18e"), "num" : 500 }
>

Range Queries

More interestingly,you can also issue range queries using the special $gt and $lt operators.

>
> db.numbers.find({num: {"$gt": 20, "$lt":25 }})
{ "_id" : ObjectId("623d669b7f64c5090cc0afaf"), "num" : 21 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb0"), "num" : 22 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb1"), "num" : 23 }
{ "_id" : ObjectId("623d669b7f64c5090cc0afb2"), "num" : 24 }
> db.numbers.find({num: {"$gt": 19995 }})
{ "_id" : ObjectId("623d66a27f64c5090cc0fdb6"), "num" : 19996 }
{ "_id" : ObjectId("623d66a27f64c5090cc0fdb7"), "num" : 19997 }
{ "_id" : ObjectId("623d66a27f64c5090cc0fdb8"), "num" : 19998 }
{ "_id" : ObjectId("623d66a27f64c5090cc0fdb9"), "num" : 19999 }
>

indexing and explain()

query explain ,an invaluable tool for debugging or optimizing a query.

explain describes query paths and allows developers to diagnose slow operations by determining which indexes a query has used.

> db.numbers.find({num: {"$gt": 19995}}).explain("executionStats")
{
        "explainVersion" : "1",
        "queryPlanner" : {
                "namespace" : "tutorial.numbers",
                "indexFilterSet" : false,
                "parsedQuery" : {
                        "num" : {
                                "$gt" : 19995
                        }
                },
                "maxIndexedOrSolutionsReached" : false,
                "maxIndexedAndSolutionsReached" : false,
                "maxScansToExplodeReached" : false,
                "winningPlan" : {
                        "stage" : "COLLSCAN",
                        "filter" : {
                                "num" : {
                                        "$gt" : 19995
                                }
                        },
                        "direction" : "forward"
                },
                "rejectedPlans" : [ ]
        },
        "executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 4,
                "executionTimeMillis" : 50,
                "totalKeysExamined" : 0,
                "totalDocsExamined" : 20000,
                "executionStages" : {
                        "stage" : "COLLSCAN",
                        "filter" : {
                                "num" : {
                                        "$gt" : 19995
                                }
                        },
                        "nReturned" : 4,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 20002,
                        "advanced" : 4,
                        "needTime" : 19997,
                        "needYield" : 0,
                        "saveState" : 21,
                        "restoreState" : 21,
                        "isEOF" : 1,
                        "direction" : "forward",
                        "docsExamined" : 20000
                }
        },
        "command" : {
                "find" : "numbers",
                "filter" : {
                        "num" : {
                                "$gt" : 19995
                        }
                },
                "$db" : "tutorial"
        },
        "serverInfo" : {
                "host" : "MaxwellPan",
                "port" : 27017,
                "version" : "5.0.6",
                "gitVersion" : "212a8dbb47f07427dae194a9c75baec1d81d9259"
        },
        "serverParameters" : {
                "internalQueryFacetBufferSizeBytes" : 104857600,
                "internalQueryFacetMaxOutputDocSizeBytes" : 104857600,
                "internalLookupStageIntermediateDocumentMaxSizeBytes" : 104857600,
                "internalDocumentSourceGroupMaxMemoryBytes" : 104857600,
                "internalQueryMaxBlockingSortMemoryUsageBytes" : 104857600,
                "internalQueryProhibitBlockingMergeOnMongoS" : 0,
                "internalQueryMaxAddToSetBytes" : 104857600,
                "internalDocumentSourceSetWindowFieldsMaxMemoryBytes" : 104857600
        },
        "ok" : 1
}
>

What this collection needs is an index.You can create an index for the num key within the documents using the createIndex() method.Try entering the following index creation code:

> db.numbers.createIndex({num: 1})
{
        "numIndexesBefore" : 1,
        "numIndexesAfter" : 2,
        "createdCollectionAutomatically" : false,
        "ok" : 1
}
>

You can verify that the index has been created by calling the getIndexes() method:

>
> db.numbers.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "num" : 1
                },
                "name" : "num_1"
        }
]
>

The collection now has two indexes.The first is the standard _id index that's automatically built for every collection;the second is the index you created on num.

> db.numbers.find({num: {"$gt": 19995}}).explain("executionStats")
{
        "explainVersion" : "1",
        "queryPlanner" : {
                "namespace" : "tutorial.numbers",
                "indexFilterSet" : false,
                "parsedQuery" : {
                        "num" : {
                                "$gt" : 19995
                        }
                },
                "maxIndexedOrSolutionsReached" : false,
                "maxIndexedAndSolutionsReached" : false,
                "maxScansToExplodeReached" : false,
                "winningPlan" : {
                        "stage" : "FETCH",
                        "inputStage" : {
                                "stage" : "IXSCAN",
                                "keyPattern" : {
                                        "num" : 1
                                },
                                "indexName" : "num_1",
                                "isMultiKey" : false,
                                "multiKeyPaths" : {
                                        "num" : [ ]
                                },
                                "isUnique" : false,
                                "isSparse" : false,
                                "isPartial" : false,
                                "indexVersion" : 2,
                                "direction" : "forward",
                                "indexBounds" : {
                                        "num" : [
                                                "(19995.0, inf.0]"
                                        ]
                                }
                        }
                },
                "rejectedPlans" : [ ]
        },
        "executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 4,
                "executionTimeMillis" : 94,
                "totalKeysExamined" : 4,
                "totalDocsExamined" : 4,
                "executionStages" : {
                        "stage" : "FETCH",
                        "nReturned" : 4,

                        "executionTimeMillisEstimate" : 52,
                        "works" : 5,
                        "advanced" : 4,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 1,
                        "restoreState" : 1,
                        "isEOF" : 1,
                        "docsExamined" : 4,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                                "stage" : "IXSCAN",
                                "nReturned" : 4,
                                "executionTimeMillisEstimate" : 52,
                                "works" : 5,
                                "advanced" : 4,
                                "needTime" : 0,
                                "needYield" : 0,
                                "saveState" : 1,
                                "restoreState" : 1,
                                "isEOF" : 1,
                                "keyPattern" : {
                                        "num" : 1
                                },
                                "indexName" : "num_1",
                                "isMultiKey" : false,
                                "multiKeyPaths" : {
                                        "num" : [ ]
                                },
                                "isUnique" : false,
                                "isSparse" : false,
                                "isPartial" : false,
                                "indexVersion" : 2,
                                "direction" : "forward",
                                "indexBounds" : {
                                        "num" : [
                                                "(19995.0, inf.0]"
                                        ]
                                },
                                "keysExamined" : 4,
                                "seeks" : 1,
                                "dupsTested" : 0,
                                "dupsDropped" : 0
                        }
                }
        },
        "command" : {
                "find" : "numbers",
                "filter" : {
                        "num" : {
                                "$gt" : 19995
                        }
                },
                "$db" : "tutorial"
        },
        "serverInfo" : {
                "host" : "MaxwellPan",
                "port" : 27017,
                "version" : "5.0.6",
                "gitVersion" : "212a8dbb47f07427dae194a9c75baec1d81d9259"
        },
        "serverParameters" : {
                "internalQueryFacetBufferSizeBytes" : 104857600,
                "internalQueryFacetMaxOutputDocSizeBytes" : 104857600,
                "internalLookupStageIntermediateDocumentMaxSizeBytes" : 104857600,
                "internalDocumentSourceGroupMaxMemoryBytes" : 104857600,
                "internalQueryMaxBlockingSortMemoryUsageBytes" : 104857600,
                "internalQueryProhibitBlockingMergeOnMongoS" : 0,
                "internalQueryMaxAddToSetBytes" : 104857600,
                "internalDocumentSourceSetWindowFieldsMaxMemoryBytes" : 104857600
        },
        "ok" : 1
}
>

Getting database information

> show dbs
admin     0.000GB
config    0.000GB
flights   0.000GB
local     0.000GB
shop      0.000GB
tutorial  0.001GB
>
> show collections
numbers
>
> db.stats()
{
        "db" : "tutorial",
        "collections" : 1,
        "views" : 0,
        "objects" : 20000,
        "avgObjSize" : 35,
        "dataSize" : 700000,
        "storageSize" : 262144,
        "indexes" : 2,
        "indexSize" : 466944,
        "totalSize" : 729088,
        "scaleFactor" : 1,
        "fsUsedSize" : 640395595776,
        "fsTotalSize" : 1000203087872,
        "ok" : 1
}
> db.numbers.stats()
{
        "ns" : "tutorial.numbers",
        "size" : 700000,
        "count" : 20000,
        "avgObjSize" : 35,
        "storageSize" : 262144,
        "freeStorageSize" : 0,
        "capped" : false,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1
                },
                "creationString" : "access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=snappy,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none",
                "type" : "file",
                "uri" : "statistics:table:collection-6--3336646001336899247",
                "LSM" : {
                        "bloom filter false positives" : 0,
                        "bloom filter hits" : 0,
                        "bloom filter misses" : 0,
                        "bloom filter pages evicted from cache" : 0,
                        "bloom filter pages read into cache" : 0,
                        "bloom filters in the LSM tree" : 0,
                        "chunks in the LSM tree" : 0,
                        "highest merge generation in the LSM tree" : 0,
                        "queries that could have benefited from a Bloom filter that did not exist" : 0,
                        "sleep for LSM checkpoint throttle" : 0,
                        "sleep for LSM merge throttle" : 0,
                        "total size of bloom filters" : 0
                },
                "block-manager" : {
                        "allocations requiring file extension" : 10,
                        "blocks allocated" : 10,
                        "blocks freed" : 0,
                        "checkpoint size" : 245760,
                        "file allocation unit size" : 4096,
                        "file bytes available for reuse" : 0,
                        "file magic number" : 120897,
                        "file major version number" : 1,
                        "file size in bytes" : 262144,
                        "minor version number" : 0
                },
                "btree" : {
                        "btree checkpoint generation" : 1282,
                        "btree clean tree checkpoint expiration time" : NumberLong("9223372036854775807"),
                        "btree compact pages reviewed" : 0,
                        "btree compact pages rewritten" : 0,
                        "btree compact pages skipped" : 0,
                        "btree skipped by compaction as process would not reduce size" : 0,
                        "column-store fixed-size leaf pages" : 0,
                        "column-store internal pages" : 0,
                        "column-store variable-size RLE encoded values" : 0,
                        "column-store variable-size deleted values" : 0,
                        "column-store variable-size leaf pages" : 0,
                        "fixed-record size" : 0,
                        "maximum internal page size" : 4096,
                        "maximum leaf page key size" : 2867,
                        "maximum leaf page size" : 32768,
                        "maximum leaf page value size" : 67108864,
                        "maximum tree depth" : 3,
                        "number of key/value pairs" : 0,
                        "overflow pages" : 0,
                        "row-store empty values" : 0,
                        "row-store internal pages" : 0,
                        "row-store leaf pages" : 0
                },
                "cache" : {
                        "bytes currently in the cache" : 2706327,
                        "bytes dirty in the cache cumulative" : 865,
                        "bytes read into cache" : 0,
                        "bytes written from cache" : 791840,
                        "checkpoint blocked page eviction" : 0,
                        "checkpoint of history store file blocked non-history store page eviction" : 0,
                        "data source pages selected for eviction unable to be evicted" : 0,
                        "eviction gave up due to detecting an out of order on disk value behind the last update on the chain" : 0,
                        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update" : 0,
                        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain" : 0,
                        "eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update" : 0,
                        "eviction walk passes of a file" : 0,
                        "eviction walk target pages histogram - 0-9" : 0,
                        "eviction walk target pages histogram - 10-31" : 0,
                        "eviction walk target pages histogram - 128 and higher" : 0,
                        "eviction walk target pages histogram - 32-63" : 0,
                        "eviction walk target pages histogram - 64-128" : 0,
                        "eviction walk target pages reduced due to history store cache pressure" : 0,
                        "eviction walks abandoned" : 0,
                        "eviction walks gave up because they restarted their walk twice" : 0,
                        "eviction walks gave up because they saw too many pages and found no candidates" : 0,
                        "eviction walks gave up because they saw too many pages and found too few candidates" : 0,
                        "eviction walks reached end of tree" : 0,
                        "eviction walks restarted" : 0,
                        "eviction walks started from root of tree" : 0,
                        "eviction walks started from saved location in tree" : 0,
                        "hazard pointer blocked page eviction" : 0,
                        "history store table insert calls" : 0,
                        "history store table insert calls that returned restart" : 0,
                        "history store table out-of-order resolved updates that lose their durable timestamp" : 0,
                        "history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp" : 0,
                        "history store table reads" : 0,
                        "history store table reads missed" : 0,
                        "history store table reads requiring squashed modifies" : 0,
                        "history store table truncation by rollback to stable to remove an unstable update" : 0,
                        "history store table truncation by rollback to stable to remove an update" : 0,
                        "history store table truncation to remove an update" : 0,
                        "history store table truncation to remove range of updates due to key being removed from the data page during reconciliation" : 0,
                        "history store table truncation to remove range of updates due to out-of-order timestamp update on data page" : 0,
                        "history store table writes requiring squashed modifies" : 0,
                        "in-memory page passed criteria to be split" : 0,
                        "in-memory page splits" : 0,
                        "internal pages evicted" : 0,
                        "internal pages split during eviction" : 0,
                        "leaf pages split during eviction" : 0,
                        "modified pages evicted" : 0,
                        "overflow pages read into cache" : 0,
                        "page split during eviction deepened the tree" : 0,
                        "page written requiring history store records" : 0,
                        "pages read into cache" : 0,
                        "pages read into cache after truncate" : 1,
                        "pages read into cache after truncate in prepare state" : 0,
                        "pages requested from the cache" : 20174,
                        "pages seen by eviction walk" : 0,
                        "pages written from cache" : 8,
                        "pages written requiring in-memory restoration" : 0,
                        "the number of times full update inserted to history store" : 0,
                        "the number of times reverse modify inserted to history store" : 0,
                        "tracked dirty bytes in the cache" : 0,
                        "unmodified pages evicted" : 0
                },
                "cache_walk" : {
                        "Average difference between current eviction generation when the page was last considered" : 0,
                        "Average on-disk page image size seen" : 0,
                        "Average time in cache for pages that have been visited by the eviction server" : 0,
                        "Average time in cache for pages that have not been visited by the eviction server" : 0,
                        "Clean pages currently in cache" : 0,
                        "Current eviction generation" : 0,
                        "Dirty pages currently in cache" : 0,
                        "Entries in the root page" : 0,
                        "Internal pages currently in cache" : 0,
                        "Leaf pages currently in cache" : 0,
                        "Maximum difference between current eviction generation when the page was last considered" : 0,
                        "Maximum page size seen" : 0,
                        "Minimum on-disk page image size seen" : 0,
                        "Number of pages never visited by eviction server" : 0,
                        "On-disk page image sizes smaller than a single allocation unit" : 0,
                        "Pages created in memory and never written" : 0,
                        "Pages currently queued for eviction" : 0,
                        "Pages that could not be queued for eviction" : 0,
                        "Refs skipped during cache traversal" : 0,
                        "Size of the root page" : 0,
                        "Total number of pages currently in cache" : 0
                },
                "checkpoint-cleanup" : {
                        "pages added for eviction" : 0,
                        "pages removed" : 0,
                        "pages skipped during tree walk" : 0,
                        "pages visited" : 1
                },
                "compression" : {
                        "compressed page maximum internal page size prior to compression" : 4096,
                        "compressed page maximum leaf page size prior to compression " : 111416,
                        "compressed pages read" : 0,
                        "compressed pages written" : 7,
                        "number of blocks with compress ratio greater than 64" : 0,
                        "number of blocks with compress ratio smaller than 16" : 0,
                        "number of blocks with compress ratio smaller than 2" : 0,
                        "number of blocks with compress ratio smaller than 32" : 0,
                        "number of blocks with compress ratio smaller than 4" : 0,
                        "number of blocks with compress ratio smaller than 64" : 0,
                        "number of blocks with compress ratio smaller than 8" : 0,
                        "page written failed to compress" : 0,
                        "page written was too small to compress" : 1
                },
                "cursor" : {
                        "Total number of entries skipped by cursor next calls" : 0,
                        "Total number of entries skipped by cursor prev calls" : 0,
                        "Total number of entries skipped to position the history store cursor" : 0,
                        "Total number of times a search near has exited due to prefix config" : 0,
                        "bulk loaded cursor insert calls" : 0,
                        "cache cursors reuse count" : 20010,
                        "close calls that result in cache" : 20012,
                        "create calls" : 2,
                        "cursor next calls that skip due to a globally visible history store tombstone" : 0,
                        "cursor next calls that skip greater than or equal to 100 entries" : 0,
                        "cursor next calls that skip less than 100 entries" : 160111,
                        "cursor prev calls that skip due to a globally visible history store tombstone" : 0,
                        "cursor prev calls that skip greater than or equal to 100 entries" : 0,
                        "cursor prev calls that skip less than 100 entries" : 1,
                        "insert calls" : 20000,
                        "insert key and value bytes" : 751426,
                        "modify" : 0,
                        "modify key and value bytes affected" : 0,
                        "modify value bytes modified" : 0,
                        "next calls" : 160111,
                        "open cursor count" : 0,
                        "operation restarted" : 0,
                        "prev calls" : 1,
                        "remove calls" : 0,
                        "remove key bytes removed" : 0,
                        "reserve calls" : 0,
                        "reset calls" : 40189,
                        "search calls" : 4,
                        "search history store calls" : 0,
                        "search near calls" : 160,
                        "truncate calls" : 0,
                        "update calls" : 0,
                        "update key and value bytes" : 0,
                        "update value size change" : 0
                },
                "reconciliation" : {
                        "approximate byte size of timestamps in pages written" : 0,
                        "approximate byte size of transaction IDs in pages written" : 0,
                        "dictionary matches" : 0,
                        "fast-path pages deleted" : 0,
                        "internal page key bytes discarded using suffix compression" : 13,
                        "internal page multi-block writes" : 0,
                        "leaf page key bytes discarded using prefix compression" : 0,
                        "leaf page multi-block writes" : 1,
                        "leaf-page overflow keys" : 0,
                        "maximum blocks required for a page" : 1,
                        "overflow values written" : 0,
                        "page checksum matches" : 0,
                        "page reconciliation calls" : 2,
                        "page reconciliation calls for eviction" : 0,
                        "pages deleted" : 0,
                        "pages written including an aggregated newest start durable timestamp " : 0,
                        "pages written including an aggregated newest stop durable timestamp " : 0,
                        "pages written including an aggregated newest stop timestamp " : 0,
                        "pages written including an aggregated newest stop transaction ID" : 0,
                        "pages written including an aggregated newest transaction ID " : 0,
                        "pages written including an aggregated oldest start timestamp " : 0,
                        "pages written including an aggregated prepare" : 0,
                        "pages written including at least one prepare" : 0,
                        "pages written including at least one start durable timestamp" : 0,
                        "pages written including at least one start timestamp" : 0,
                        "pages written including at least one start transaction ID" : 0,
                        "pages written including at least one stop durable timestamp" : 0,
                        "pages written including at least one stop timestamp" : 0,
                        "pages written including at least one stop transaction ID" : 0,
                        "records written including a prepare" : 0,
                        "records written including a start durable timestamp" : 0,
                        "records written including a start timestamp" : 0,
                        "records written including a start transaction ID" : 0,
                        "records written including a stop durable timestamp" : 0,
                        "records written including a stop timestamp" : 0,
                        "records written including a stop transaction ID" : 0
                },
                "session" : {
                        "object compaction" : 0,
                        "tiered operations dequeued and processed" : 0,
                        "tiered operations scheduled" : 0,
                        "tiered storage local retention time (secs)" : 0,
                        "tiered storage object size" : 0
                },
                "transaction" : {
                        "race to read prepared update retry" : 0,
                        "rollback to stable history store records with stop timestamps older than newer records" : 0,
                        "rollback to stable inconsistent checkpoint" : 0,
                        "rollback to stable keys removed" : 0,
                        "rollback to stable keys restored" : 0,
                        "rollback to stable restored tombstones from history store" : 0,
                        "rollback to stable restored updates from history store" : 0,
                        "rollback to stable skipping delete rle" : 0,
                        "rollback to stable skipping stable rle" : 0,
                        "rollback to stable sweeping history store keys" : 0,
                        "rollback to stable updates removed from history store" : 0,
                        "transaction checkpoints due to obsolete pages" : 0,
                        "update conflicts" : 0
                }
        },
        "nindexes" : 2,
        "indexBuilds" : [ ],
        "totalIndexSize" : 466944,
        "totalSize" : 729088,
        "indexSizes" : {
                "_id_" : 229376,
                "num_1" : 237568
        },
        "scaleFactor" : 1,
        "ok" : 1
}
>

Some of the values provided in these result documents are useful only in complicated debugging or tuning situations.But at the very least, you'll be able to find out how much space a given collection and its indexes are occupying.

How commands work

> db.stats()

The stats() method is a helper that wraps the shell's command invocation method.Try enterring the following equivalent operation:

> db.runCommand({dbstats: 1})
{
        "db" : "tutorial",
        "collections" : 1,
        "views" : 0,
        "objects" : 20000,
        "avgObjSize" : 35,
        "dataSize" : 700000,
        "storageSize" : 262144,
        "indexes" : 2,
        "indexSize" : 466944,
        "totalSize" : 729088,
        "scaleFactor" : 1,
        "fsUsedSize" : 640395583488,
        "fsTotalSize" : 1000203087872,
        "ok" : 1
}
>

In general,you can run any available command by passing its document definition to the runCommand() method.

> db.runCommand({collstats: "numbers"})
{
        "ns" : "tutorial.numbers",
        "size" : 700000,
        "count" : 20000,
        "avgObjSize" : 35,
        "storageSize" : 262144,
        "freeStorageSize" : 0,
        "capped" : false,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1
                },
                "creationString" : "access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=snappy,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none",
                "type" : "file",
                "uri" : "statistics:table:collection-6--3336646001336899247",
                "LSM" : {
                        "bloom filter false positives" : 0,
                        "bloom filter hits" : 0,
                        "bloom filter misses" : 0,
                        "bloom filter pages evicted from cache" : 0,
                        "bloom filter pages read into cache" : 0,
                        "bloom filters in the LSM tree" : 0,
                        "chunks in the LSM tree" : 0,
                        "highest merge generation in the LSM tree" : 0,
                        "queries that could have benefited from a Bloom filter that did not exist" : 0,
                        "sleep for LSM checkpoint throttle" : 0,
                        "sleep for LSM merge throttle" : 0,
                        "total size of bloom filters" : 0
                },
                "block-manager" : {
                        "allocations requiring file extension" : 10,
                        "blocks allocated" : 10,
                        "blocks freed" : 0,
                        "checkpoint size" : 245760,
                        "file allocation unit size" : 4096,
                        "file bytes available for reuse" : 0,
                        "file magic number" : 120897,
                        "file major version number" : 1,
                        "file size in bytes" : 262144,
                        "minor version number" : 0
                },
                "btree" : {
                        "btree checkpoint generation" : 1291,
                        "btree clean tree checkpoint expiration time" : NumberLong("9223372036854775807"),
                        "btree compact pages reviewed" : 0,
                        "btree compact pages rewritten" : 0,
                        "btree compact pages skipped" : 0,
                        "btree skipped by compaction as process would not reduce size" : 0,
                        "column-store fixed-size leaf pages" : 0,
                        "column-store internal pages" : 0,
                        "column-store variable-size RLE encoded values" : 0,
                        "column-store variable-size deleted values" : 0,
                        "column-store variable-size leaf pages" : 0,
                        "fixed-record size" : 0,
                        "maximum internal page size" : 4096,
                        "maximum leaf page key size" : 2867,
                        "maximum leaf page size" : 32768,
                        "maximum leaf page value size" : 67108864,
                        "maximum tree depth" : 3,
                        "number of key/value pairs" : 0,
                        "overflow pages" : 0,
                        "row-store empty values" : 0,
                        "row-store internal pages" : 0,
                        "row-store leaf pages" : 0
                },
                "cache" : {
                        "bytes currently in the cache" : 2706327,
                        "bytes dirty in the cache cumulative" : 865,
                        "bytes read into cache" : 0,
                        "bytes written from cache" : 791840,
                        "checkpoint blocked page eviction" : 0,
                        "checkpoint of history store file blocked non-history store page eviction" : 0,
                        "data source pages selected for eviction unable to be evicted" : 0,
                        "eviction gave up due to detecting an out of order on disk value behind the last update on the chain" : 0,
                        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update" : 0,
                        "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain" : 0,
                        "eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update" : 0,
                        "eviction walk passes of a file" : 0,
                        "eviction walk target pages histogram - 0-9" : 0,
                        "eviction walk target pages histogram - 10-31" : 0,
                        "eviction walk target pages histogram - 128 and higher" : 0,
                        "eviction walk target pages histogram - 32-63" : 0,
                        "eviction walk target pages histogram - 64-128" : 0,
                        "eviction walk target pages reduced due to history store cache pressure" : 0,
                        "eviction walks abandoned" : 0,
                        "eviction walks gave up because they restarted their walk twice" : 0,
                        "eviction walks gave up because they saw too many pages and found no candidates" : 0,
                        "eviction walks gave up because they saw too many pages and found too few candidates" : 0,
                        "eviction walks reached end of tree" : 0,
                        "eviction walks restarted" : 0,
                        "eviction walks started from root of tree" : 0,
                        "eviction walks started from saved location in tree" : 0,
                        "hazard pointer blocked page eviction" : 0,
                        "history store table insert calls" : 0,
                        "history store table insert calls that returned restart" : 0,
                        "history store table out-of-order resolved updates that lose their durable timestamp" : 0,
                        "history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp" : 0,
                        "history store table reads" : 0,
                        "history store table reads missed" : 0,
                        "history store table reads requiring squashed modifies" : 0,
                        "history store table truncation by rollback to stable to remove an unstable update" : 0,
                        "history store table truncation by rollback to stable to remove an update" : 0,
                        "history store table truncation to remove an update" : 0,
                        "history store table truncation to remove range of updates due to key being removed from the data page during reconciliation" : 0,
                        "history store table truncation to remove range of updates due to out-of-order timestamp update on data page" : 0,
                        "history store table writes requiring squashed modifies" : 0,
                        "in-memory page passed criteria to be split" : 0,
                        "in-memory page splits" : 0,
                        "internal pages evicted" : 0,
                        "internal pages split during eviction" : 0,
                        "leaf pages split during eviction" : 0,
                        "modified pages evicted" : 0,
                        "overflow pages read into cache" : 0,
                        "page split during eviction deepened the tree" : 0,
                        "page written requiring history store records" : 0,
                        "pages read into cache" : 0,
                        "pages read into cache after truncate" : 1,
                        "pages read into cache after truncate in prepare state" : 0,
                        "pages requested from the cache" : 20174,
                        "pages seen by eviction walk" : 0,
                        "pages written from cache" : 8,
                        "pages written requiring in-memory restoration" : 0,
                        "the number of times full update inserted to history store" : 0,
                        "the number of times reverse modify inserted to history store" : 0,
                        "tracked dirty bytes in the cache" : 0,
                        "unmodified pages evicted" : 0
                },
                "cache_walk" : {
                        "Average difference between current eviction generation when the page was last considered" : 0,
                        "Average on-disk page image size seen" : 0,
                        "Average time in cache for pages that have been visited by the eviction server" : 0,
                        "Average time in cache for pages that have not been visited by the eviction server" : 0,
                        "Clean pages currently in cache" : 0,
                        "Current eviction generation" : 0,
                        "Dirty pages currently in cache" : 0,
                        "Entries in the root page" : 0,
                        "Internal pages currently in cache" : 0,
                        "Leaf pages currently in cache" : 0,
                        "Maximum difference between current eviction generation when the page was last considered" : 0,
                        "Maximum page size seen" : 0,
                        "Minimum on-disk page image size seen" : 0,
                        "Number of pages never visited by eviction server" : 0,
                        "On-disk page image sizes smaller than a single allocation unit" : 0,
                        "Pages created in memory and never written" : 0,
                        "Pages currently queued for eviction" : 0,
                        "Pages that could not be queued for eviction" : 0,
                        "Refs skipped during cache traversal" : 0,
                        "Size of the root page" : 0,
                        "Total number of pages currently in cache" : 0
                },
                "checkpoint-cleanup" : {
                        "pages added for eviction" : 0,
                        "pages removed" : 0,
                        "pages skipped during tree walk" : 0,
                        "pages visited" : 1
                },
                "compression" : {
                        "compressed page maximum internal page size prior to compression" : 4096,
                        "compressed page maximum leaf page size prior to compression " : 111416,
                        "compressed pages read" : 0,
                        "compressed pages written" : 7,
                        "number of blocks with compress ratio greater than 64" : 0,
                        "number of blocks with compress ratio smaller than 16" : 0,
                        "number of blocks with compress ratio smaller than 2" : 0,
                        "number of blocks with compress ratio smaller than 32" : 0,
                        "number of blocks with compress ratio smaller than 4" : 0,
                        "number of blocks with compress ratio smaller than 64" : 0,
                        "number of blocks with compress ratio smaller than 8" : 0,
                        "page written failed to compress" : 0,
                        "page written was too small to compress" : 1
                },
                "cursor" : {
                        "Total number of entries skipped by cursor next calls" : 0,
                        "Total number of entries skipped by cursor prev calls" : 0,
                        "Total number of entries skipped to position the history store cursor" : 0,
                        "Total number of times a search near has exited due to prefix config" : 0,
                        "bulk loaded cursor insert calls" : 0,
                        "cache cursors reuse count" : 20010,
                        "close calls that result in cache" : 20012,
                        "create calls" : 2,
                        "cursor next calls that skip due to a globally visible history store tombstone" : 0,
                        "cursor next calls that skip greater than or equal to 100 entries" : 0,
                        "cursor next calls that skip less than 100 entries" : 160111,
                        "cursor prev calls that skip due to a globally visible history store tombstone" : 0,
                        "cursor prev calls that skip greater than or equal to 100 entries" : 0,
                        "cursor prev calls that skip less than 100 entries" : 1,
                        "insert calls" : 20000,
                        "insert key and value bytes" : 751426,
                        "modify" : 0,
                        "modify key and value bytes affected" : 0,
                        "modify value bytes modified" : 0,
                        "next calls" : 160111,
                        "open cursor count" : 0,
                        "operation restarted" : 0,
                        "prev calls" : 1,
                        "remove calls" : 0,
                        "remove key bytes removed" : 0,
                        "reserve calls" : 0,
                        "reset calls" : 40189,
                        "search calls" : 4,
                        "search history store calls" : 0,
                        "search near calls" : 160,
                        "truncate calls" : 0,
                        "update calls" : 0,
                        "update key and value bytes" : 0,
                        "update value size change" : 0
                },
                "reconciliation" : {
                        "approximate byte size of timestamps in pages written" : 0,
                        "approximate byte size of transaction IDs in pages written" : 0,
                        "dictionary matches" : 0,
                        "fast-path pages deleted" : 0,
                        "internal page key bytes discarded using suffix compression" : 13,
                        "internal page multi-block writes" : 0,
                        "leaf page key bytes discarded using prefix compression" : 0,
                        "leaf page multi-block writes" : 1,
                        "leaf-page overflow keys" : 0,
                        "maximum blocks required for a page" : 1,
                        "overflow values written" : 0,
                        "page checksum matches" : 0,
                        "page reconciliation calls" : 2,
                        "page reconciliation calls for eviction" : 0,
                        "pages deleted" : 0,
                        "pages written including an aggregated newest start durable timestamp " : 0,
                        "pages written including an aggregated newest stop durable timestamp " : 0,
                        "pages written including an aggregated newest stop timestamp " : 0,
                        "pages written including an aggregated newest stop transaction ID" : 0,
                        "pages written including an aggregated newest transaction ID " : 0,
                        "pages written including an aggregated oldest start timestamp " : 0,
                        "pages written including an aggregated prepare" : 0,
                        "pages written including at least one prepare" : 0,
                        "pages written including at least one start durable timestamp" : 0,
                        "pages written including at least one start timestamp" : 0,
                        "pages written including at least one start transaction ID" : 0,
                        "pages written including at least one stop durable timestamp" : 0,
                        "pages written including at least one stop timestamp" : 0,
                        "pages written including at least one stop transaction ID" : 0,
                        "records written including a prepare" : 0,
                        "records written including a start durable timestamp" : 0,
                        "records written including a start timestamp" : 0,
                        "records written including a start transaction ID" : 0,
                        "records written including a stop durable timestamp" : 0,
                        "records written including a stop timestamp" : 0,
                        "records written including a stop transaction ID" : 0
                },
                "session" : {
                        "object compaction" : 0,
                        "tiered operations dequeued and processed" : 0,
                        "tiered operations scheduled" : 0,
                        "tiered storage local retention time (secs)" : 0,
                        "tiered storage object size" : 0
                },
                "transaction" : {
                        "race to read prepared update retry" : 0,
                        "rollback to stable history store records with stop timestamps older than newer records" : 0,
                        "rollback to stable inconsistent checkpoint" : 0,
                        "rollback to stable keys removed" : 0,
                        "rollback to stable keys restored" : 0,
                        "rollback to stable restored tombstones from history store" : 0,
                        "rollback to stable restored updates from history store" : 0,
                        "rollback to stable skipping delete rle" : 0,
                        "rollback to stable skipping stable rle" : 0,
                        "rollback to stable sweeping history store keys" : 0,
                        "rollback to stable updates removed from history store" : 0,
                        "transaction checkpoints due to obsolete pages" : 0,
                        "update conflicts" : 0
                }
        },
        "nindexes" : 2,
        "indexDetails" : {
                "_id_" : {
                        "metadata" : {
                                "formatVersion" : 8
                        },
                        "creationString" : "access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=8),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=16k,key_format=u,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=16k,leaf_value_max=0,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=true,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none",
                        "type" : "file",
                        "uri" : "statistics:table:index-7--3336646001336899247",
                        "LSM" : {
                                "bloom filter false positives" : 0,
                                "bloom filter hits" : 0,
                                "bloom filter misses" : 0,
                                "bloom filter pages evicted from cache" : 0,
                                "bloom filter pages read into cache" : 0,
                                "bloom filters in the LSM tree" : 0,
                                "chunks in the LSM tree" : 0,
                                "highest merge generation in the LSM tree" : 0,
                                "queries that could have benefited from a Bloom filter that did not exist" : 0,
                                "sleep for LSM checkpoint throttle" : 0,
                                "sleep for LSM merge throttle" : 0,
                                "total size of bloom filters" : 0
                        },
                        "block-manager" : {
                                "allocations requiring file extension" : 16,
                                "blocks allocated" : 16,
                                "blocks freed" : 0,
                                "checkpoint size" : 212992,
                                "file allocation unit size" : 4096,
                                "file bytes available for reuse" : 0,
                                "file magic number" : 120897,
                                "file major version number" : 1,
                                "file size in bytes" : 229376,
                                "minor version number" : 0
                        },
                        "btree" : {
                                "btree checkpoint generation" : 1291,
                                "btree clean tree checkpoint expiration time" : NumberLong("9223372036854775807"),
                                "btree compact pages reviewed" : 0,
                                "btree compact pages rewritten" : 0,
                                "btree compact pages skipped" : 0,
                                "btree skipped by compaction as process would not reduce size" : 0,
                                "column-store fixed-size leaf pages" : 0,
                                "column-store internal pages" : 0,
                                "column-store variable-size RLE encoded values" : 0,
                                "column-store variable-size deleted values" : 0,
                                "column-store variable-size leaf pages" : 0,
                                "fixed-record size" : 0,
                                "maximum internal page size" : 16384,
                                "maximum leaf page key size" : 1474,
                                "maximum leaf page size" : 16384,
                                "maximum leaf page value size" : 7372,
                                "maximum tree depth" : 3,
                                "number of key/value pairs" : 0,
                                "overflow pages" : 0,
                                "row-store empty values" : 0,
                                "row-store internal pages" : 0,
                                "row-store leaf pages" : 0
                        },
                        "cache" : {
                                "bytes currently in the cache" : 2261659,
                                "bytes dirty in the cache cumulative" : 865,
                                "bytes read into cache" : 0,
                                "bytes written from cache" : 193456,
                                "checkpoint blocked page eviction" : 0,
                                "checkpoint of history store file blocked non-history store page eviction" : 0,
                                "data source pages selected for eviction unable to be evicted" : 0,
                                "eviction gave up due to detecting an out of order on disk value behind the last update on the chain" : 0,
                                "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update" : 0,
                                "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain" : 0,
                                "eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update" : 0,
                                "eviction walk passes of a file" : 0,
                                "eviction walk target pages histogram - 0-9" : 0,
                                "eviction walk target pages histogram - 10-31" : 0,
                                "eviction walk target pages histogram - 128 and higher" : 0,
                                "eviction walk target pages histogram - 32-63" : 0,
                                "eviction walk target pages histogram - 64-128" : 0,
                                "eviction walk target pages reduced due to history store cache pressure" : 0,
                                "eviction walks abandoned" : 0,
                                "eviction walks gave up because they restarted their walk twice" : 0,
                                "eviction walks gave up because they saw too many pages and found no candidates" : 0,
                                "eviction walks gave up because they saw too many pages and found too few candidates" : 0,
                                "eviction walks reached end of tree" : 0,
                                "eviction walks restarted" : 0,
                                "eviction walks started from root of tree" : 0,
                                "eviction walks started from saved location in tree" : 0,
                                "hazard pointer blocked page eviction" : 0,
                                "history store table insert calls" : 0,
                                "history store table insert calls that returned restart" : 0,
                                "history store table out-of-order resolved updates that lose their durable timestamp" : 0,
                                "history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp" : 0,
                                "history store table reads" : 0,
                                "history store table reads missed" : 0,
                                "history store table reads requiring squashed modifies" : 0,
                                "history store table truncation by rollback to stable to remove an unstable update" : 0,
                                "history store table truncation by rollback to stable to remove an update" : 0,
                                "history store table truncation to remove an update" : 0,
                                "history store table truncation to remove range of updates due to key being removed from the data page during reconciliation" : 0,
                                "history store table truncation to remove range of updates due to out-of-order timestamp update on data page" : 0,
                                "history store table writes requiring squashed modifies" : 0,
                                "in-memory page passed criteria to be split" : 0,
                                "in-memory page splits" : 0,
                                "internal pages evicted" : 0,
                                "internal pages split during eviction" : 0,
                                "leaf pages split during eviction" : 0,
                                "modified pages evicted" : 0,
                                "overflow pages read into cache" : 0,
                                "page split during eviction deepened the tree" : 0,
                                "page written requiring history store records" : 0,
                                "pages read into cache" : 0,
                                "pages read into cache after truncate" : 1,
                                "pages read into cache after truncate in prepare state" : 0,
                                "pages requested from the cache" : 20001,
                                "pages seen by eviction walk" : 0,
                                "pages written from cache" : 14,
                                "pages written requiring in-memory restoration" : 0,
                                "the number of times full update inserted to history store" : 0,
                                "the number of times reverse modify inserted to history store" : 0,
                                "tracked dirty bytes in the cache" : 0,
                                "unmodified pages evicted" : 0
                        },
                        "cache_walk" : {
                                "Average difference between current eviction generation when the page was last considered" : 0,
                                "Average on-disk page image size seen" : 0,
                                "Average time in cache for pages that have been visited by the eviction server" : 0,
                                "Average time in cache for pages that have not been visited by the eviction server" : 0,
                                "Clean pages currently in cache" : 0,
                                "Current eviction generation" : 0,
                                "Dirty pages currently in cache" : 0,
                                "Entries in the root page" : 0,
                                "Internal pages currently in cache" : 0,
                                "Leaf pages currently in cache" : 0,
                                "Maximum difference between current eviction generation when the page was last considered" : 0,
                                "Maximum page size seen" : 0,
                                "Minimum on-disk page image size seen" : 0,
                                "Number of pages never visited by eviction server" : 0,
                                "On-disk page image sizes smaller than a single allocation unit" : 0,
                                "Pages created in memory and never written" : 0,
                                "Pages currently queued for eviction" : 0,
                                "Pages that could not be queued for eviction" : 0,
                                "Refs skipped during cache traversal" : 0,
                                "Size of the root page" : 0,
                                "Total number of pages currently in cache" : 0
                        },
                        "checkpoint-cleanup" : {
                                "pages added for eviction" : 0,
                                "pages removed" : 0,
                                "pages skipped during tree walk" : 0,
                                "pages visited" : 1
                        },
                        "compression" : {
                                "compressed page maximum internal page size prior to compression" : 16384,
                                "compressed page maximum leaf page size prior to compression " : 16384,
                                "compressed pages read" : 0,
                                "compressed pages written" : 0,
                                "number of blocks with compress ratio greater than 64" : 0,
                                "number of blocks with compress ratio smaller than 16" : 0,
                                "number of blocks with compress ratio smaller than 2" : 0,
                                "number of blocks with compress ratio smaller than 32" : 0,
                                "number of blocks with compress ratio smaller than 4" : 0,
                                "number of blocks with compress ratio smaller than 64" : 0,
                                "number of blocks with compress ratio smaller than 8" : 0,
                                "page written failed to compress" : 0,
                                "page written was too small to compress" : 0
                        },
                        "cursor" : {
                                "Total number of entries skipped by cursor next calls" : 0,
                                "Total number of entries skipped by cursor prev calls" : 0,
                                "Total number of entries skipped to position the history store cursor" : 0,
                                "Total number of times a search near has exited due to prefix config" : 0,
                                "bulk loaded cursor insert calls" : 0,
                                "cache cursors reuse count" : 19998,
                                "close calls that result in cache" : 20000,
                                "create calls" : 2,
                                "cursor next calls that skip due to a globally visible history store tombstone" : 0,
                                "cursor next calls that skip greater than or equal to 100 entries" : 0,
                                "cursor next calls that skip less than 100 entries" : 0,
                                "cursor prev calls that skip due to a globally visible history store tombstone" : 0,
                                "cursor prev calls that skip greater than or equal to 100 entries" : 0,
                                "cursor prev calls that skip less than 100 entries" : 0,
                                "insert calls" : 20000,
                                "insert key and value bytes" : 338977,
                                "modify" : 0,
                                "modify key and value bytes affected" : 0,
                                "modify value bytes modified" : 0,
                                "next calls" : 0,
                                "open cursor count" : 0,
                                "operation restarted" : 0,
                                "prev calls" : 0,
                                "remove calls" : 0,
                                "remove key bytes removed" : 0,
                                "reserve calls" : 0,
                                "reset calls" : 40000,
                                "search calls" : 0,
                                "search history store calls" : 0,
                                "search near calls" : 0,
                                "truncate calls" : 0,
                                "update calls" : 0,
                                "update key and value bytes" : 0,
                                "update value size change" : 0
                        },
                        "reconciliation" : {
                                "approximate byte size of timestamps in pages written" : 0,
                                "approximate byte size of transaction IDs in pages written" : 0,
                                "dictionary matches" : 0,
                                "fast-path pages deleted" : 0,
                                "internal page key bytes discarded using suffix compression" : 52,
                                "internal page multi-block writes" : 0,
                                "leaf page key bytes discarded using prefix compression" : 206591,
                                "leaf page multi-block writes" : 1,
                                "leaf-page overflow keys" : 0,
                                "maximum blocks required for a page" : 1,
                                "overflow values written" : 0,
                                "page checksum matches" : 0,
                                "page reconciliation calls" : 2,
                                "page reconciliation calls for eviction" : 0,
                                "pages deleted" : 0,
                                "pages written including an aggregated newest start durable timestamp " : 0,
                                "pages written including an aggregated newest stop durable timestamp " : 0,
                                "pages written including an aggregated newest stop timestamp " : 0,
                                "pages written including an aggregated newest stop transaction ID" : 0,
                                "pages written including an aggregated newest transaction ID " : 0,
                                "pages written including an aggregated oldest start timestamp " : 0,
                                "pages written including an aggregated prepare" : 0,
                                "pages written including at least one prepare" : 0,
                                "pages written including at least one start durable timestamp" : 0,
                                "pages written including at least one start timestamp" : 0,
                                "pages written including at least one start transaction ID" : 0,
                                "pages written including at least one stop durable timestamp" : 0,
                                "pages written including at least one stop timestamp" : 0,
                                "pages written including at least one stop transaction ID" : 0,
                                "records written including a prepare" : 0,
                                "records written including a start durable timestamp" : 0,
                                "records written including a start timestamp" : 0,
                                "records written including a start transaction ID" : 0,
                                "records written including a stop durable timestamp" : 0,
                                "records written including a stop timestamp" : 0,
                                "records written including a stop transaction ID" : 0
                        },
                        "session" : {
                                "object compaction" : 0,
                                "tiered operations dequeued and processed" : 0,
                                "tiered operations scheduled" : 0,
                                "tiered storage local retention time (secs)" : 0,
                                "tiered storage object size" : 0
                        },
                        "transaction" : {
                                "race to read prepared update retry" : 0,
                                "rollback to stable history store records with stop timestamps older than newer records" : 0,
                                "rollback to stable inconsistent checkpoint" : 0,
                                "rollback to stable keys removed" : 0,
                                "rollback to stable keys restored" : 0,
                                "rollback to stable restored tombstones from history store" : 0,
                                "rollback to stable restored updates from history store" : 0,
                                "rollback to stable skipping delete rle" : 0,
                                "rollback to stable skipping stable rle" : 0,
                                "rollback to stable sweeping history store keys" : 0,
                                "rollback to stable updates removed from history store" : 0,
                                "transaction checkpoints due to obsolete pages" : 0,
                                "update conflicts" : 0
                        }
                },
                "num_1" : {
                        "metadata" : {
                                "formatVersion" : 8
                        },
                        "creationString" : "access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=8),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=16k,key_format=u,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=16k,leaf_value_max=0,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=true,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none",
                        "type" : "file",
                        "uri" : "statistics:table:index-8--3336646001336899247",
                        "LSM" : {
                                "bloom filter false positives" : 0,
                                "bloom filter hits" : 0,
                                "bloom filter misses" : 0,
                                "bloom filter pages evicted from cache" : 0,
                                "bloom filter pages read into cache" : 0,
                                "bloom filters in the LSM tree" : 0,
                                "chunks in the LSM tree" : 0,
                                "highest merge generation in the LSM tree" : 0,
                                "queries that could have benefited from a Bloom filter that did not exist" : 0,
                                "sleep for LSM checkpoint throttle" : 0,
                                "sleep for LSM merge throttle" : 0,
                                "total size of bloom filters" : 0
                        },
                        "block-manager" : {
                                "allocations requiring file extension" : 0,
                                "blocks allocated" : 0,
                                "blocks freed" : 0,
                                "checkpoint size" : 221184,
                                "file allocation unit size" : 4096,
                                "file bytes available for reuse" : 0,
                                "file magic number" : 120897,
                                "file major version number" : 1,
                                "file size in bytes" : 237568,
                                "minor version number" : 0
                        },
                        "btree" : {
                                "btree checkpoint generation" : 1291,
                                "btree clean tree checkpoint expiration time" : NumberLong("9223372036854775807"),
                                "btree compact pages reviewed" : 0,
                                "btree compact pages rewritten" : 0,
                                "btree compact pages skipped" : 0,
                                "btree skipped by compaction as process would not reduce size" : 0,
                                "column-store fixed-size leaf pages" : 0,
                                "column-store internal pages" : 0,
                                "column-store variable-size RLE encoded values" : 0,
                                "column-store variable-size deleted values" : 0,
                                "column-store variable-size leaf pages" : 0,
                                "fixed-record size" : 0,
                                "maximum internal page size" : 16384,
                                "maximum leaf page key size" : 1474,
                                "maximum leaf page size" : 16384,
                                "maximum leaf page value size" : 7372,
                                "maximum tree depth" : 3,
                                "number of key/value pairs" : 0,
                                "overflow pages" : 0,
                                "row-store empty values" : 0,
                                "row-store internal pages" : 0,
                                "row-store leaf pages" : 0
                        },
                        "cache" : {
                                "bytes currently in the cache" : 16416,
                                "bytes dirty in the cache cumulative" : 0,
                                "bytes read into cache" : 8024,
                                "bytes written from cache" : 0,
                                "checkpoint blocked page eviction" : 0,
                                "checkpoint of history store file blocked non-history store page eviction" : 0,
                                "data source pages selected for eviction unable to be evicted" : 0,
                                "eviction gave up due to detecting an out of order on disk value behind the last update on the chain" : 0,
                                "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update" : 0,
                                "eviction gave up due to detecting an out of order tombstone ahead of the selected on disk update after validating the update chain" : 0,
                                "eviction gave up due to detecting out of order timestamps on the update chain after the selected on disk update" : 0,
                                "eviction walk passes of a file" : 0,
                                "eviction walk target pages histogram - 0-9" : 0,
                                "eviction walk target pages histogram - 10-31" : 0,
                                "eviction walk target pages histogram - 128 and higher" : 0,
                                "eviction walk target pages histogram - 32-63" : 0,
                                "eviction walk target pages histogram - 64-128" : 0,
                                "eviction walk target pages reduced due to history store cache pressure" : 0,
                                "eviction walks abandoned" : 0,
                                "eviction walks gave up because they restarted their walk twice" : 0,
                                "eviction walks gave up because they saw too many pages and found no candidates" : 0,
                                "eviction walks gave up because they saw too many pages and found too few candidates" : 0,
                                "eviction walks reached end of tree" : 0,
                                "eviction walks restarted" : 0,
                                "eviction walks started from root of tree" : 0,
                                "eviction walks started from saved location in tree" : 0,
                                "hazard pointer blocked page eviction" : 0,
                                "history store table insert calls" : 0,
                                "history store table insert calls that returned restart" : 0,
                                "history store table out-of-order resolved updates that lose their durable timestamp" : 0,
                                "history store table out-of-order updates that were fixed up by reinserting with the fixed timestamp" : 0,
                                "history store table reads" : 0,
                                "history store table reads missed" : 0,
                                "history store table reads requiring squashed modifies" : 0,
                                "history store table truncation by rollback to stable to remove an unstable update" : 0,
                                "history store table truncation by rollback to stable to remove an update" : 0,
                                "history store table truncation to remove an update" : 0,
                                "history store table truncation to remove range of updates due to key being removed from the data page during reconciliation" : 0,
                                "history store table truncation to remove range of updates due to out-of-order timestamp update on data page" : 0,
                                "history store table writes requiring squashed modifies" : 0,
                                "in-memory page passed criteria to be split" : 0,
                                "in-memory page splits" : 0,
                                "internal pages evicted" : 0,
                                "internal pages split during eviction" : 0,
                                "leaf pages split during eviction" : 0,
                                "modified pages evicted" : 0,
                                "overflow pages read into cache" : 0,
                                "page split during eviction deepened the tree" : 0,
                                "page written requiring history store records" : 0,
                                "pages read into cache" : 2,
                                "pages read into cache after truncate" : 0,
                                "pages read into cache after truncate in prepare state" : 0,
                                "pages requested from the cache" : 2,
                                "pages seen by eviction walk" : 0,
                                "pages written from cache" : 0,
                                "pages written requiring in-memory restoration" : 0,
                                "the number of times full update inserted to history store" : 0,
                                "the number of times reverse modify inserted to history store" : 0,
                                "tracked dirty bytes in the cache" : 0,
                                "unmodified pages evicted" : 0
                        },
                        "cache_walk" : {
                                "Average difference between current eviction generation when the page was last considered" : 0,
                                "Average on-disk page image size seen" : 0,
                                "Average time in cache for pages that have been visited by the eviction server" : 0,
                                "Average time in cache for pages that have not been visited by the eviction server" : 0,
                                "Clean pages currently in cache" : 0,
                                "Current eviction generation" : 0,
                                "Dirty pages currently in cache" : 0,
                                "Entries in the root page" : 0,
                                "Internal pages currently in cache" : 0,
                                "Leaf pages currently in cache" : 0,
                                "Maximum difference between current eviction generation when the page was last considered" : 0,
                                "Maximum page size seen" : 0,
                                "Minimum on-disk page image size seen" : 0,
                                "Number of pages never visited by eviction server" : 0,
                                "On-disk page image sizes smaller than a single allocation unit" : 0,
                                "Pages created in memory and never written" : 0,
                                "Pages currently queued for eviction" : 0,
                                "Pages that could not be queued for eviction" : 0,
                                "Refs skipped during cache traversal" : 0,
                                "Size of the root page" : 0,
                                "Total number of pages currently in cache" : 0
                        },
                        "checkpoint-cleanup" : {
                                "pages added for eviction" : 0,
                                "pages removed" : 0,
                                "pages skipped during tree walk" : 0,
                                "pages visited" : 0
                        },
                        "compression" : {
                                "compressed page maximum internal page size prior to compression" : 16384,
                                "compressed page maximum leaf page size prior to compression " : 16384,
                                "compressed pages read" : 0,
                                "compressed pages written" : 0,
                                "number of blocks with compress ratio greater than 64" : 0,
                                "number of blocks with compress ratio smaller than 16" : 0,
                                "number of blocks with compress ratio smaller than 2" : 0,
                                "number of blocks with compress ratio smaller than 32" : 0,
                                "number of blocks with compress ratio smaller than 4" : 0,
                                "number of blocks with compress ratio smaller than 64" : 0,
                                "number of blocks with compress ratio smaller than 8" : 0,
                                "page written failed to compress" : 0,
                                "page written was too small to compress" : 0
                        },
                        "cursor" : {
                                "Total number of entries skipped by cursor next calls" : 0,
                                "Total number of entries skipped by cursor prev calls" : 0,
                                "Total number of entries skipped to position the history store cursor" : 0,
                                "Total number of times a search near has exited due to prefix config" : 0,
                                "bulk loaded cursor insert calls" : 0,
                                "cache cursors reuse count" : 0,
                                "close calls that result in cache" : 1,
                                "create calls" : 1,
                                "cursor next calls that skip due to a globally visible history store tombstone" : 0,
                                "cursor next calls that skip greater than or equal to 100 entries" : 0,
                                "cursor next calls that skip less than 100 entries" : 5,
                                "cursor prev calls that skip due to a globally visible history store tombstone" : 0,
                                "cursor prev calls that skip greater than or equal to 100 entries" : 0,
                                "cursor prev calls that skip less than 100 entries" : 0,
                                "insert calls" : 0,
                                "insert key and value bytes" : 0,
                                "modify" : 0,
                                "modify key and value bytes affected" : 0,
                                "modify value bytes modified" : 0,
                                "next calls" : 5,
                                "open cursor count" : 0,
                                "operation restarted" : 0,
                                "prev calls" : 0,
                                "remove calls" : 0,
                                "remove key bytes removed" : 0,
                                "reserve calls" : 0,
                                "reset calls" : 3,
                                "search calls" : 0,
                                "search history store calls" : 0,
                                "search near calls" : 2,
                                "truncate calls" : 0,
                                "update calls" : 0,
                                "update key and value bytes" : 0,
                                "update value size change" : 0
                        },
                        "reconciliation" : {
                                "approximate byte size of timestamps in pages written" : 0,
                                "approximate byte size of transaction IDs in pages written" : 0,
                                "dictionary matches" : 0,
                                "fast-path pages deleted" : 0,
                                "internal page key bytes discarded using suffix compression" : 0,
                                "internal page multi-block writes" : 0,
                                "leaf page key bytes discarded using prefix compression" : 0,
                                "leaf page multi-block writes" : 0,
                                "leaf-page overflow keys" : 0,
                                "maximum blocks required for a page" : 0,
                                "overflow values written" : 0,
                                "page checksum matches" : 0,
                                "page reconciliation calls" : 0,
                                "page reconciliation calls for eviction" : 0,
                                "pages deleted" : 0,
                                "pages written including an aggregated newest start durable timestamp " : 0,
                                "pages written including an aggregated newest stop durable timestamp " : 0,
                                "pages written including an aggregated newest stop timestamp " : 0,
                                "pages written including an aggregated newest stop transaction ID" : 0,
                                "pages written including an aggregated newest transaction ID " : 0,
                                "pages written including an aggregated oldest start timestamp " : 0,
                                "pages written including an aggregated prepare" : 0,
                                "pages written including at least one prepare" : 0,
                                "pages written including at least one start durable timestamp" : 0,
                                "pages written including at least one start timestamp" : 0,
                                "pages written including at least one start transaction ID" : 0,
                                "pages written including at least one stop durable timestamp" : 0,
                                "pages written including at least one stop timestamp" : 0,
                                "pages written including at least one stop transaction ID" : 0,
                                "records written including a prepare" : 0,
                                "records written including a start durable timestamp" : 0,
                                "records written including a start timestamp" : 0,
                                "records written including a start transaction ID" : 0,
                                "records written including a stop durable timestamp" : 0,
                                "records written including a stop timestamp" : 0,
                                "records written including a stop transaction ID" : 0
                        },
                        "session" : {
                                "object compaction" : 0,
                                "tiered operations dequeued and processed" : 0,
                                "tiered operations scheduled" : 0,
                                "tiered storage local retention time (secs)" : 0,
                                "tiered storage object size" : 0
                        },
                        "transaction" : {
                                "race to read prepared update retry" : 0,
                                "rollback to stable history store records with stop timestamps older than newer records" : 0,
                                "rollback to stable inconsistent checkpoint" : 0,
                                "rollback to stable keys removed" : 0,
                                "rollback to stable keys restored" : 0,
                                "rollback to stable restored tombstones from history store" : 0,
                                "rollback to stable restored updates from history store" : 0,
                                "rollback to stable skipping delete rle" : 0,
                                "rollback to stable skipping stable rle" : 0,
                                "rollback to stable sweeping history store keys" : 0,
                                "rollback to stable updates removed from history store" : 0,
                                "transaction checkpoints due to obsolete pages" : 0,
                                "update conflicts" : 0
                        }
                }
        },
        "indexBuilds" : [ ],
        "totalIndexSize" : 466944,
        "totalSize" : 729088,
        "indexSizes" : {
                "_id_" : 229376,
                "num_1" : 237568
        },
        "scaleFactor" : 1,
        "ok" : 1
}

You can execute the parentheses-less version and the internals:

> db.runCommand
function(obj, extra, queryOptions) {
    "use strict";

    // Support users who call this function with a string commandName, e.g.
    // db.runCommand("commandName", {arg1: "value", arg2: "value"}).
    var mergedObj = this._mergeCommandOptions(obj, extra);

    // if options were passed (i.e. because they were overridden on a collection), use them.
    // Otherwise use getQueryOptions.
    var options = (typeof (queryOptions) !== "undefined") ? queryOptions : this.getQueryOptions();

    try {
        return this._runCommandImpl(this._name, mergedObj, options);
    } catch (ex) {
        // When runCommand flowed through query, a connection error resulted in the message
        // "error doing query: failed". Even though this message is arguably incorrect
        // for a command failing due to a connection failure, we preserve it for backwards
        // compatibility. See SERVER-18334 for details.
        if (ex.message.indexOf("network error") >= 0) {
            throw new Error("error doing query: failed: " + ex.message);
        }
        throw ex;
    }
}
>

> db.$cmd.findOne({collstats: "numbers"});
{
        "ns" : "tutorial.numbers",
        "size" : 700000,
        "count" : 20000,
        "avgObjSize" : 35,
        "storageSize" : 262144,
        "freeStorageSize" : 0,
        "capped" : false,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1
                },
                "creationString" : "access_pattern_hint=none,allocation_size=4KB,app_metadata=(formatVersion=1),assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none,write_timestamp=off),block_allocation=best,block_compressor=snappy,cache_resident=false,checksum=on,colgroups=,collator=,columns=,dictionary=0,encryption=(keyid=,name=),exclusive=false,extractor=,format=btree,huffman_key=,huffman_value=,ignore_in_memory_cache_size=false,immutable=false,import=(enabled=false,file_metadata=,repair=false),internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=q,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=64MB,log=(enabled=true),lsm=(auto_throttle=true,bloom=true,bloom_bit_count=16,bloom_config=,bloom_hash_count=8,bloom_oldest=false,chunk_count_limit=0,chunk_max=5GB,chunk_size=10MB,merge_custom=(prefix=,start_generation=0,suffix=),merge_max=15,merge_min=0),memory_page_image_max=0,memory_page_max=10m,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,readonly=false,source=,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,tiered_object=false,tiered_storage=(auth_token=,bucket=,bucket_prefix=,cache_directory=,local_retention=300,name=,object_target_size=10M),type=file,value_format=u,verbose=[],write_timestamp_usage=none",

Getting help

> db.numbers.help()
DBCollection help
        db.numbers.find().help() - show DBCursor help
        db.numbers.bulkWrite( operations, <optional params> ) - bulk execute write operations, optional parameters are: w, wtimeout, j
        db.numbers.count( query = {}, <optional params> ) - count the number of documents that matches the query, optional parameters are: limit, skip, hint, maxTimeMS
        db.numbers.countDocuments( query = {}, <optional params> ) - count the number of documents that matches the query, optional parameters are: limit, skip, hint, maxTimeMS
        db.numbers.estimatedDocumentCount( <optional params> ) - estimate the document count using collection metadata, optional parameters are: maxTimeMS
        db.numbers.convertToCapped(maxBytes) - calls {convertToCapped:'numbers', size:maxBytes}} command
        db.numbers.createIndex(keypattern[,options])
        db.numbers.createIndexes([keypatterns], <options>)
        db.numbers.dataSize()
        db.numbers.deleteOne( filter, <optional params> ) - delete first matching document, optional parameters are: w, wtimeout, j
        db.numbers.deleteMany( filter, <optional params> ) - delete all matching documents, optional parameters are: w, wtimeout, j
        db.numbers.distinct( key, query, <optional params> ) - e.g. db.numbers.distinct( 'x' ), optional parameters are: maxTimeMS
        db.numbers.drop() drop the collection
        db.numbers.dropIndex(index) - e.g. db.numbers.dropIndex( "indexName" ) or db.numbers.dropIndex( { "indexKey" : 1 } )
        db.numbers.hideIndex(index) - e.g. db.numbers.hideIndex( "indexName" ) or db.numbers.hideIndex( { "indexKey" : 1 } )
        db.numbers.unhideIndex(index) - e.g. db.numbers.unhideIndex( "indexName" ) or db.numbers.unhideIndex( { "indexKey" : 1 } )
        db.numbers.dropIndexes()
        db.numbers.explain().help() - show explain help
        db.numbers.reIndex()
        db.numbers.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
                                                      e.g. db.numbers.find( {x:77} , {name:1, x:1} )
        db.numbers.find(...).count()
        db.numbers.find(...).limit(n)
        db.numbers.find(...).skip(n)
        db.numbers.find(...).sort(...)
        db.numbers.findOne([query], [fields], [options], [readConcern])
        db.numbers.findOneAndDelete( filter, <optional params> ) - delete first matching document, optional parameters are: projection, sort, maxTimeMS
        db.numbers.findOneAndReplace( filter, replacement, <optional params> ) - replace first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
        db.numbers.findOneAndUpdate( filter, <update object or pipeline>, <optional params> ) - update first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
        db.numbers.getDB() get DB object associated with collection
        db.numbers.getPlanCache() get query plan cache associated with collection
        db.numbers.getIndexes()
        db.numbers.insert(obj)
        db.numbers.insertOne( obj, <optional params> ) - insert a document, optional parameters are: w, wtimeout, j
        db.numbers.insertMany( [objects], <optional params> ) - insert multiple documents, optional parameters are: w, wtimeout, j
        db.numbers.mapReduce( mapFunction , reduceFunction , <optional params> )
        db.numbers.aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor
        db.numbers.remove(query)
        db.numbers.replaceOne( filter, replacement, <optional params> ) - replace the first matching document, optional parameters are: upsert, w, wtimeout, j
        db.numbers.renameCollection( newName , <dropTarget> ) renames the collection.
        db.numbers.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
        db.numbers.save(obj)
        db.numbers.stats({scale: N, indexDetails: true/false, indexDetailsKey: <index key>, indexDetailsName: <index name>})
        db.numbers.storageSize() - includes free space allocated to this collection
        db.numbers.totalIndexSize() - size in bytes of all the indexes
        db.numbers.totalSize() - storage allocated for all data and indexes
        db.numbers.update( query, <update object or pipeline>[, upsert_bool, multi_bool] ) - instead of two flags, you can pass an object with fields: upsert, multi, hint, let
        db.numbers.updateOne( filter, <update object or pipeline>, <optional params> ) - update the first matching document, optional parameters are: upsert, w, wtimeout, j, hint, let
        db.numbers.updateMany( filter, <update object or pipeline>, <optional params> ) - update all matching documents, optional parameters are: upsert, w, wtimeout, j, hint, let
        db.numbers.validate( <full> ) - SLOW
        db.numbers.getShardVersion() - only for use with sharding
        db.numbers.getShardDistribution() - prints statistics about data distribution in the cluster
        db.numbers.getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function
        db.numbers.getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set
        db.numbers.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection
        db.numbers.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection
        db.numbers.latencyStats() - display operation latency histograms for this collection
>

>
> db.numbers.save({num:123123123})
WriteResult({ "nInserted" : 1 })
> db.numbers.save
function(obj, opts) {
    if (obj == null)
        throw Error("can't save a null");

    if (typeof (obj) == "number" || typeof (obj) == "string")
        throw Error("can't save a number or string");

    if (typeof (obj._id) == "undefined") {
        obj._id = new ObjectId();
        return this.insert(obj, opts);
    } else {
        return this.update({_id: obj._id}, obj, Object.merge({upsert: true}, opts));
    }
}
>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值