MongoDB Space Collation

Source: Internet
Author: User
Tags compact

Test environment: 192.168.1.55, stand-alone
Data Volume: 40 million or so.
Test: Db.repairedatabase Effect
Db.compact effect
Get information about the database by using the stats command:
Db.stats () {"DB": "Test",
"Collections": 7, Number of--collection
"Objects": 28,--Number of objects
"Avgobjsize": 50.57142857142857,--average size of the object
"DataSize": 1416,--Data size
"Storagesize": 31744,--data size (including pre-allocated space)
"Numextents": 7,--Number of events
"Indexes": 7,--Number of indexes
"Indexsize": 57344,--Index size
"FileSize": 50331648,--File size
"OK": 1--Stats is normal to take this time
} >

1. Before data is deleted

Show DBS

AA 0.000GB
Admin 0.000GB
Gwgps 3.609GB
Local 0.000GB

Db.stats ()

{
"DB": "Gwgps",
"Collections": 1,
"Objects": 41345131,
"Avgobjsize": 554.8684502656431,
"DataSize": 22941108764,
"Storagesize": 3081945088,
"Numextents": 0,
"Indexes": 3,
"Indexsize": 792702976,
"OK": 1
}

2. After the program deletes the N bar

Show DBS

AA 0.000GB
Admin 0.000GB
Gwgps 3.610GB
Local 0.000GB

Db.stats ()

{
"DB": "Gwgps",
"Collections": 1,
"Objects": 41344233,
"Avgobjsize": 554.8684691284514,
"DataSize": 22940611272,
"Storagesize": 3081945088,
"Numextents": 0,
"Indexes": 3,
"Indexsize": 794288128,
"OK": 1
}

After 3.repaireDatabase

Db.repairdatabase ()

{"OK": 1}

Show DBS

AA 0.000GB
Admin 0.000GB
Gwgps 3.609GB
Local 0.000GB

Db.stats ()

{
"DB": "Gwgps",
"Collections": 1,
"Objects": 41344233,
"Avgobjsize": 554.8684691284514,
"DataSize": 22940611272,
"Storagesize": 3081945088,
"Numextents": 0,
"Indexes": 3,
"Indexsize": 792682496,
"OK": 1
}

4.compact command
> Db.runcommand ({compact: ' location '}) {"OK": 1}

Show DBS

AA 0.000GB
Admin 0.000GB
Gwgps 3.612GB
Local 0.000GB

Db.stats ()

{
"DB": "Gwgps",
"Collections": 1,
"Objects": 41337719,
"Avgobjsize": 554.8686059818637,
"DataSize": 22937002516,
"Storagesize": 3081945088,
"Numextents": 0,
"Indexes": 3,
"Indexsize": 795889664,
"OK": 1
}

After repeated multiple deletions, using repairedatabase,show dbs, Du-sh command to view the space, the following conclusions are obtained:
1. When using Db.repairdatabase, it is recommended to stop the database read and write, need more than equal to the data space, otherwise you may not be able to execute the command.
2.40 million data repairdatabase takes about 10 minutes, 4 billion, 40 billion, 400 billion effects to be measured.
3. Storagesize This value is not reduced because it has a positive meaning, including pre-allocated space.
4. The actual space is reduced by the space occupied by the index.
5. Space controllable can disable log or log polling for replication, but is not recommended.
6. Prohibit pre-allocated space or pre-set allocation space (Noprealloc parameter can be selected when starting the database), but affect the efficiency of insertion.
7. Recommend appropriate timing compression, use compact compression to specify collection, or RepairDatabase compression database.

MongoDB Space Collation

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.