Mongodb_ limit Set (Capped)

Source: Internet
Author: User

1, overview

A set of restrictions is a special set in MongoDB; his size is fixed, the storage rules follow the fisrt-in-fisrt-out FIFO principle!


2, judging/creating/converting

Determines whether the set belongs to the restricted set db.collection.isCapped ();

Restricted collections must be created manually, cut to the specified size!    (Other collections do not have to be created manually) db.createcollection ("log", {capped:true,size:1024,max:500}); Capped Description collection type size specified collection physical size max Limit number of document bars

Normal collection converted to restriction set: Db.runcommand ({"converttocapped": "Mycoll", size:100000});

3, add data/Update data

The limit set adds data, and if the limit set size is exceeded, the first entry to the document is deleted and written to the new document;

Update data: You can do a document in-place update. If this update operation causes the document to grow beyond their original size, the update operation will fail. If you plan to update the document in a restricted set, create an index so that the update operation does not require a table-level scan

Fragment related post-supplement;

Mongodb_ limit Set (Capped)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.