MongoDB 2.0 new features look at the compact Command

Source: Internet
Author: User
Keywords This run new features so

Today, the company opened the mailbox and was pleasantly surprised to find http://www.aliyun.com/zixun/aggregation/13461.html ">mongodb's News Letter, Open a look unexpectedly is 2.0 update, haha, so can't wait to start to try, because I usually only maintain the database, does not involve the development part, all the understanding is limited, most of the translation mainly. The following is the official document address: http://www.mongodb.org/display/DOCS/2.0+920.html ">release+notes?mkt_tok= 3rkmmjwwff9wsronv6tpzkxonjhpfsx%2b6eopwkag38431ufwdcjkpmjr1yicrmt0dvycmravfzl5nv0ihewb# 2.0releasenotes-journalingenhancements

Compact Command Collation

In fact, I do not know exactly what should be translated into what is more appropriate, its role is to organize collection, the contents of which are all extracted after the rearrangement of neat, a bit like the system of disk collation, so I called it. Before version 2.0, a similar operation was required to use the collation command to operate in collection. There are two ways to use this command:

Db.runcommand ({compact: ' Mycollcetionname '}) Db.mycollction.runCommand ("compact")

This command is not returned until it is finished, either through the Mongod log file to view the process record, or in another MONGO instance, to remotely view the in-memory state of the collection being sorted by command Db.currentop (). In particular, it is not possible to perform other operations when this command is run, so it is recommended to be used in replica sets. Also, when used in replica sets, there are a number of considerations:

For the primary instance in the replica sets, running this command directly will cause an error, and you need to use Force:true as a parameter to force the operation, so it is not recommended to run on the primary. For the secondary instance in replica sets, when you start running this command, the instance automatically drops to the "recovery" state until the command completes. In the entire replica set, a compact operation is required on each instance, and the behavior of this collation does not automatically synchronize.

The official documentation provides instructions that the obvious effect of a compact operation is to remove all the Padding factor,padding Factor in the database MONGO a portion of the disk space that is reserved for increasing the efficiency of data operations, So in fact, the compact function is not entirely suitable for the need to update the Collection, but for the more stable less frequently update operation of the database, it can improve the speed of the query.

In addition to kill the compact process to pay special attention to, the compact operation is to remove all the content from a collection, and then rebuild them in the collection, so breaking the compact will result in data loss. At this point, Journal is needed to reduce this loss. Journal in 1.9+ as a key test feature, because considering it is still unstable, I did not dare to try it in the actual project, only made a few small tests, 2.0 it is officially debut, I will be good to love it = v =, the above content is basically taken from official documents, I will attach the actual experiment later.

Related Article

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.