http://docs.mongodb.org/manual/reference/limits/MongoDB Limits and ThresholdsThis document provides a collection of hard and soft limitations ofthe MongoDB system.BSON DocumentsBSON Document SizeThe maximum BSON document size is 16 megabytes.The maximum document size helps ensure that a single document cannotuse excessive amount of RAM or, during transmission, excessive amountof bandwidth. To store documents larger than the maximum size, MongoDBprovides the GridFS API. See mongofiles and thedocumentation for your driver for moreinformation about GridFS.Nested Depth for BSON DocumentsChanged in version 2.2.MongoDB supports no more than 100 levels of nesting for BSONdocuments.NamespacesNamespace LengthEach namespace, including database and collection name, must beshorter than 123 bytes.Number of NamespacesThe limitation on the number of namespaces is the size of thenamespace file divided by 628.A 16 megabyte namespace file can support approximately 24,000namespaces. 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 thesize using the nssize option.IndexesIndex KeyThe total size of an indexed value must be less than 1024bytes. MongoDB will not add that value to an index if it is longerthan 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 andcollection name) cannot be longer than 125 characters. The defaultindex name is the concatenation of the field names and indexdirections.You can explicitly specify an index name to the ensureIndex() helper if the default indexname 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 text command, which requires aspecial text index, with a query operatorthat requires a different type of special index. For example youcannot combine text with the $near operator.See alsoThe unique indexes limit in Sharding Operational Restrictions.Capped CollectionsMaximum Number of Documents in a Capped CollectionChanged in version 2.4.If you specify a maximum number of documents for a cappedcollection using the max parameter to create, the limit must be less than 2 documents. If you do not specify a maximum number of documents whencreating a capped collection, there is no limit on the number ofdocuments.Replica SetsNumber of Members of a Replica SetReplica 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 giventime. See can vote Non-Voting Members for more informationSharded ClustersSharded clusters have the restrictions and thresholds described here.Sharding Operational RestrictionsOperations Unavailable in Sharded EnvironmentsThe group does not work with sharding. Use mapReduce or aggregate instead.db.eval() is incompatible with sharded collections. You mayuse db.eval() with un-sharded collections in a shardcluster.$where does not permit references to the db objectfrom the $where function. This is uncommon inun-sharded collections.The $isolated update modifier does not work in shardedenvironments.$snapshot queries do not work in sharded environments.The geoSearch command is not supported in shardedenvironments.Sharding Existing Collection Data SizeFor existing collections that hold documents, MongoDB supportsenabling sharding on any collections that contains less than 256gigabytes of data. MongoDB may be able to shard collections with asmany as 400 gigabytes depending on the distribution of documentsizes. The precise size of the limitation is a function of thechunk size and the data size.ImportantSharded collections may have any size, aftersuccessfully enabling sharding.Single Document Modification Operations in Sharded CollectionsAll single update() and remove() operations must include the shard key or the _id field in the queryspecification. update() or remove() operations that affect a singledocument in a sharded collection without the shard key or the _id field return an error.Unique Indexes in Sharded CollectionsMongoDB does not support unique indexes across shards, except whenthe unique index contains the full shard key as a prefix of theindex. In these situations MongoDB will enforce uniqueness acrossthe full key, not a single field.SeeEnforce Unique Keys for Sharded Collections for an alternate approach.Shard Key LimitationsShard Key SizeA shard key cannot exceed 512 bytes.Shard Key is ImmutableYou cannot change a shard key after sharding the collection. Ifyou must change a shard key:Dump all data from MongoDB into an external format.Drop the original sharded collection.Configure sharding using the new shard key.Pre-split the shardkey range to ensure initial even distribution.Restore the dumped data into MongoDB.Shard Key Value in a Document is ImmutableAfter you insert a document into a sharded collection, you cannotchange the document’s value for the field or fields that comprisethe shard key. The update() operation willnot 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 withmonotonically increasing and decreasing keys can affect insertthroughput. If you use the _id field that holds default as theshard key, be aware that the default value of the _id field, ObjectID values, this shard key will be monotonicallyincreasing because ObjectID values increment as time-stamps.When inserting documents with monotonically increasing shard keys, allinserts belong to the same chunk on a single shard. The system will eventually divide thechunk range that receives all write operationsand migrate its contents to distribute data more evenly. However, at anymoment the cluster can direct insert operations only to a singleshard, which creates an insert throughput bottleneck.If the operations on the cluster are predominately read operationsand updates, this limitation may not affect the cluster.To avoid this constraint, use a hashed shard key or select a field that does notincrease or decrease monotonically.Changed in version 2.4: Hashed shard keys and hashed indexes store hashes of keyswith ascending values.OperationsSorted DocumentsMongoDB will only return sorted results on fields without an index if the sort operation uses less than 32 megabytes of memory.Aggregation Sort Operation$sort produces an error if the operation consumes 10percent or more of RAM.2d Geospatial queries cannot use the $or operatorSee$or and 2d Index Internals.Spherical Polygons must fit within a hemisphere.Any geometry specified with GeoJSON to $geoIntersects or $geoWithin queries, must fit within a single hemisphere. MongoDB interpretsgeometries larger than half of the sphere as queries for the smallerof the complementary geometries.Combination Limit with Multiple $in ExpressionsQuerying with two or more $in expressions (e.g. { a: { $in: [ "a", "b", "c" ] }, b: { $in: [ "b", "c" ] } } ) can hit acombinatorial 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 therespective arrays) is equal to or greater than 4000000, MongoDB willthrow an exception of "combinatorial limit of $in partitioning of result set exceeded".Naming RestrictionsDatabase Name Case SensitivityDatabase names are case sensitive even if the underlying filesystem is case insensitive. MongoDB does not permit database namesthat differ only by the case of the characters.Restrictions on Database Names for WindowsChanged in version 2.2: Restrictions on Database Names for Windows.For MongoDB deployments running on Windows, MongoDB will not permitdatabase 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, MongoDBwill not permit database names that include any of the followingcharacters:/\. "Also, database names cannot contain the null character.Length of Database NamesDatabase names cannot be empty and must have fewer than 64characters.Restriction on Collection NamesNew in version 2.2.Collection names should begin with an underscore or a lettercharacter, and cannot:contain the $.be an empty string (e.g. "").contain the null character.begin with the system. prefix. (Reserved for internal use.)In the mongo shell, use db.getCollection() tospecify collection names that might interact with the shell or arenot 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. 10-28 18:17