Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB Notes XII-fixed set

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report