范德萨发而为
全部博文(392)
分类: 大数据
2013-11-11 09:55:36
This document provides a collection of hard and soft limitations of the MongoDB system.
The maximum BSON document size is 16 megabytes.
The maximum document size helps ensure that a single document cannot use excessive amount of RAM or, during transmission, excessive amount of bandwidth. To store documents larger than the maximum size, MongoDB provides the GridFS API. See and the documentation for your for more information about GridFS.
Nested Depth for BSON DocumentsChanged in version 2.2.
MongoDB supports no more than 100 levels of nesting for BSON documents.
Each namespace, including database and collection name, must be shorter than 123 bytes.
Number of NamespacesThe limitation on the number of namespaces is the size of the namespace file divided by 628.
A 16 megabyte namespace file can support approximately 24,000 namespaces. Each index also counts as a namespace.
Size of Namespace FileNamespace files can be no larger than 2047 megabytes.
By default namespace files are 16 megabytes. You can configure the size using the option.
The total size of an indexed value must be less than 1024 bytes. MongoDB will not add that value to an index if it is longer than 1024 bytes.
Number of Indexes per CollectionA single collection can have no more than 64 indexes.
Index Name LengthThe names of indexes, including their namespace (i.e database and collection name) cannot be longer than 125 characters. The default index name is the concatenation of the field names and index directions.
You can explicitly specify an index name to the helper if the default index name is too long.
Number of Indexed Fields in a Compound IndexThere can be no more than 31 fields in a compound index.
Queries cannot use both text and Geospatial IndexesYou cannot combine the command, which requires a special , with a query operator that requires a different type of special index. For example you cannot combine with the operator.
See also
The unique indexes limit in .
Changed in version 2.4.
If you specify a maximum number of documents for a capped collection using the max parameter to , the limit must be less than 232 documents. If you do not specify a maximum number of documents when creating a capped collection, there is no limit on the number of documents.
Replica sets can have no more than 12 members.
Number of Voting Members of a Replica SetOnly 7 members of a replica set can have votes at any given time. See can vote for more information
Sharded clusters have the restrictions and thresholds described here.
The does not work with sharding. Use or instead.
is incompatible with sharded collections. You may use with un-sharded collections in a shard cluster.
does not permit references to the db object from the function. This is uncommon in un-sharded collections.
The update modifier does not work in sharded environments.
queries do not work in sharded environments.
The command is not supported in sharded environments.
Sharding Existing Collection Data SizeFor existing collections that hold documents, MongoDB supports enabling sharding on any collections that contains less than 256 gigabytes of data. MongoDB may be able to shard collections with as many as 400 gigabytes depending on the distribution of document sizes. The precise size of the limitation is a function of the chunk size and the data size.
Important
Sharded collections may have any size, after successfully enabling sharding.
All single and operations must include the or the _id field in the query specification. or operations that affect a single document in a sharded collection without the or the _id field return an error.
Unique Indexes in Sharded CollectionsMongoDB does not support unique indexes across shards, except when the unique index contains the full shard key as a prefix of the index. In these situations MongoDB will enforce uniqueness across the full key, not a single field.
See
for an alternate approach.
A shard key cannot exceed 512 bytes.
Shard Key is ImmutableYou cannot change a shard key after sharding the collection. If you must change a shard key:
After you insert a document into a sharded collection, you cannot change the document’s value for the field or fields that comprise the shard key. The operation will not modify the value of a shard key in an existing document.
Monotonically Increasing Shard Keys Can Limit Insert ThroughputFor clusters with high insert volumes, a shard keys with monotonically increasing and decreasing keys can affect insert throughput. If you use the _id field that holds default as the shard key, be aware that the default value of the _id field, values, this shard key will be monotonically increasing because ObjectID values increment as time-stamps.
When inserting documents with monotonically increasing shard keys, all inserts belong to the same on a single . The system will eventually divide the chunk range that receives all write operations and migrate its contents to distribute data more evenly. However, at any moment the cluster can direct insert operations only to a single shard, which creates an insert throughput bottleneck.
If the operations on the cluster are predominately read operations and updates, this limitation may not affect the cluster.
To avoid this constraint, use a or select a field that does not increase or decrease monotonically.
Changed in version 2.4: and store hashes of keys with ascending values.
MongoDB will only return sorted results on fields without an index if the sort operation uses less than 32 megabytes of memory.
Aggregation Sort Operationproduces an error if the operation consumes 10 percent or more of RAM.
2d Geospatial queries cannot use the $or operatorSee
and .
Any geometry specified with to or queries, must fit within a single hemisphere. MongoDB interprets geometries larger than half of the sphere as queries for the smaller of the complementary geometries.
Combination Limit with Multiple $in ExpressionsQuerying with two or more expressions (e.g. { a: { $in: [ "a", "b", "c" ] }, b: { $in: [ "b", "c" ] } } ) can hit a combinatorial limit if the query uses a compound index on these fields (e.g. { a: 1, b: 1 } ). Specifically, if the number of combinations (i.e. the product of the number of distinct elements in the respective arrays) is equal to or greater than 4000000, MongoDB will throw an exception of "combinatorial limit of $in partitioning of result set exceeded".
Database names are case sensitive even if the underlying file system is case insensitive. MongoDB does not permit database names that differ only by the case of the characters.
Restrictions on Database Names for WindowsChanged in version 2.2: .
For MongoDB deployments running on Windows, MongoDB will not permit database names that include any of the following characters:
/\. "*<>:|?
Also, database names cannot contain the null character.
Restrictions on Database Names for Unix and Linux SystemsFor MongoDB deployments running on Unix and Linux systems, MongoDB will not permit database names that include any of the following characters:
/\. "
Also, database names cannot contain the null character.
Length of Database NamesDatabase names cannot be empty and must have fewer than 64 characters.
Restriction on Collection NamesNew in version 2.2.
Collection names should begin with an underscore or a letter character, and cannot:
In the shell, use to specify collection names that might interact with the shell or are not valid JavaScript.
Restrictions on Field NamesField names cannot contain dots (i.e. .), dollar signs (i.e. $), or null characters. See Dollar Sign Operator Escaping for an alternate approach.