The maximum number of collections that can be used in MongoDB

Source: Internet
Author: User
Tags mongodb postgresql redis

The official website has a description of the problem (Using a Large number of collections). By default, the namespace for each database of MongoDB is saved in a 16MB. ns file, with an average of about 628 bytes per name, or about 24000 of the namespace for the entire database.

Each collection and index will occupy a namespace. Therefore, if each collection has an index (such as the default _id index), you can create up to 12,000 collections. If the number of indexes is greater, the number of collections that can be created is even less. Also, if the number of collections is too many, some operations become slower.

However, if you really need to build more collections, MongoDB is also supported, just to start with the "--nssize" parameter, so that the corresponding database namespace file can be larger to save more names. This namespace file (. ns file) can be up to 2G, which means that up to 3.4 million names can be supported, and a maximum of about 1.7 million collections can be created if each collection has an index.

Also note that--nssize only sets the size of the newly created. ns file, and if you want to change the namespace of a database that already exists, you will need to run the db.repairdatabase () command to adjust the size after starting with this parameter.

Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

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.