MongoDB fixed set (capped collection)

Source: Internet
Author: User

A fixed set refers to a set that is created in advance and fixed in size.

Fixed set properties: Fixed collections are like ring queues, and if there is not enough space, the earliest documents are deleted, freeing up space for new documents. In general, fixed collections are suitable for any scenario where you want to automatically retire expired attributes, and there are not too many operational restrictions.

To create a pinned collection using the command:

Db.createcollection ("CollectionName", {capped:true,size:100000,max:100});

SIZE Specifies the collection size in Kb,max for the specified number of documents

When you specify a limit on the number of documents, you must specify both size. The elimination mechanism will only work based on the number of documents when the capacity is not yet full. If the capacity is full, the elimination mechanism will work according to capacity.

To convert a normal collection to a fixed collection:
Db.runcommand ({converttocapped: "CollectionName", size:10000,max:100});

MongoDB fixed set (capped collection)

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.