MongoDB Notes XII-fixed set
1. Characteristics of fixed sets
Fixed collections are indexed by default. Even _ id has no index.
Hesitation does not need to allocate space. His insertion speed is very fast.
The order of fixed collections is determined, resulting in very fast queries.
The most suitable application is log management.
2. Create a fixed collection
Creating a new fixed collection requires a size of 100 bytes and can store 10 documents
Db.createCollection ("mycoll", {size:100,capped:true,max:10})
Convert an ordinary set into a fixed set
Db.runCommand ({converToCapped: "persons", size:100000}) 3. Reverse sort. The default is insertion order.
Query fixed set mycoll and sort it in reverse
Db.mycoll.find (). Sort ({$natural:-1}) 4, tail cursor, but shell does not support drivers such as java and PHP.
Tail cursor concept
This is a special cursor that can only be used on a fixed level and body, and it will not destroy automatically when there is no result. He has been waiting for the result to arrive.