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

What are the features of MongoDB 1.8 RC0 version

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

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about the features of MongoDB 1.8 RC0 version, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Two days ago, MongoDB released version 1.8, and most of the descriptions I saw mentioned the improvement of adding Journaling log documents.

What are the features of the MongoDB1.8RC0 version

1.Journaling log documents increase stand-alone reliability

Well, Journaling actually means journal. Let's use it as a noun for the time being. It is used by adding the-dur option at startup. The emergence of Journaling should be attributed to the fact that some time ago, after a user used MongoDB on a stand-alone computer and then carried out a kill-9 operation, the data was not available. A description of this event can be found here.

Journaling can not only enhance the reliability of the system, but also change the restart mode of MongoDB which is not normally closed, from the original need for a long repair operation to re-execute Journaling log recording on the current data file. The speed can be greatly improved. Of course, if it is a normal shutdown, then all Journaling logs will be useless and will be erased directly.

GroupCommits Mechanism of Journaling Log

Journaling logs support the GroupCommits function, which is to combine log files for a period of time for a disk write operation. In version 1. 8, the submission interval is about 100ms.

The influence of Journaling on fsync Operation

If MongoDB is started with the-dur parameter, when the fsync command is executed, it will not be returned after fsync all the data files, but as soon as the Journaling log is written to disk.

2.SparseIndex and CoveredIndex

SparseIndex can index only one column, and the advantage of this restriction is that it does not index rows where the value of the item is empty. This greatly reduces the index size of some columns. For example, if you set up an identification of whether to delete in the list of articles, the value of deleted articles is 1, and other articles do not have this value, then the index on this value will be very small.

An example of the use of SparseIndex is as follows. You only need to add the ID with sparse as true in the second parameter:

Db.people.ensureIndex ({title:1}, {sparse:true})

CoveredIndex is in a federated index. If the value you are looking for happens to be in the index, you can directly return the value stored in the index instead of looking in the data file. (this is also implemented in traditional relational databases.)

What are the features of the MongoDB1.8RC0 version

3.Map/Reduce output mode is configurable

In version 1.8, the Map/Reduce of MongoDB no longer outputs the result to a collection, but lets the user specify how to output it when skipping the Map/Reduce task. Here are four ways to use it by adding the out parameter to the Map/Reduce command, for example:

Db.users.mapReduce (map,reduce, {out: {inline:1}})

Here are four ways:

"collectionName"-if out is set to a collection name, the output will be stored in the collection, and if the collection already exists, the data will be erased.

{merge: "collectionName"}-this option is slightly different from the one above, except that the data is not completely erased, only items that have index conflicts with the Map/Reduce results are overwritten.

{reduce: "collectionName"}-this option is a little more complex than the previous option, which does not overwrite the original data in the above case, but chooses to call the reduce method and the finalize method (if specified) to merge duplicate items.

{inline:1}-when this option is specified, the result will not be stored in a collection, but will output a data object directly, and it should be noted that it is only applicable when the resulting data is less than 8m.

These are the features of MongoDB 1.8 RC0 version, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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