You are on page 1of 3

Indexing

Create Index:

mongos> db.emp.createIndex({"place":1})

"raw" : {

"replsh/dev-cocnb-pr-34-siva03-modb-0001:27021,dev-cocnb-pr-34-siva03-modb-
0001:27022,dev-cocnb-pr-34-siva03-modb-0001:27023" : {

"createdCollectionAutomatically" : false,

"numIndexesBefore" : 3,

"numIndexesAfter" : 4,

"ok" : 1,

"$gleStats" : {

"lastOpTime" : {

"ts" : Timestamp(1504014806, 1),

"t" : NumberLong(4)

},

"electionId" : ObjectId("7fffffff0000000000000004")

},

"ok" : 1

Creating a compound index:

repl:PRIMARY> db.dept.createIndex({"name":1,"technology":1})

{
"createdCollectionAutomatically" : false,

"numIndexesBefore" : 1,

"numIndexesAfter" : 2,

"ok" : 1

Checking Total Index Size:

repl:PRIMARY> db.dept.totalIndexSize()

16352

Checking the stats:

repl:PRIMARY> db.stats()

"db" : "employee",

"collections" : 5,

"views" : 0,

"objects" : 44,

"avgObjSize" : 98.9090909090909,

"dataSize" : 4352,

"storageSize" : 36864,

"numExtents" : 5,

"indexes" : 6,

"indexSize" : 49056,

"fileSize" : 67108864,

"nsSizeMB" : 16,

"extentFreeList" : {

"num" : 5,

"totalSize" : 286720

},
"dataFileVersion" : {

"major" : 4,

"minor" : 22

},

"ok" : 1

You might also like