Naming Conventions and Suggestions of Database
The collection name cannot be a null character string "". The name should not contain the "\0" character (this indicates the end of the string). The name should not be prefixed with "system".
The name of an index is limited to 128 characters and cannot contain the '\0' character.
The database name is generally lowercase, and some characters such as spaces, ".", "$", "/", "", and "\0" are not allowed.
Design Specifications and Suggestions of Indexes
Before you design indexes, you must first determine what query operations are required. Knowing which queries are frequently executed, which queries require quick responses, and whether there are complex federated queries will help determine the strategy for creating indexes.
When selecting fields as indexes, give priority to fields that are frequently queried, as well as fields that are used as conditions in the query. At the same time, avoid creating too many indexes on large data sets.
The order of the fields in a compound index affects query performance. In general, the fields most frequently used for filter criteria are placed first in the index to narrow down the query more quickly.
Do not create indexes that will not be used. The document database loads indexes to the memory. Loading useless indexes to the memory wastes memory space. Useless indexes caused by changes in business logic should also be cleaned up in time.
If a field is frequently updated, it is best not to index the field. Because each update causes an update of an index, it consumes a lot of CPU and disk IO.
Avoid overuse of full-text indexing, which is not appropriate in all situations. The full-text indexing is suitable for complex text searches on text fields, but it is expensive to create and maintain the full-text indexing. Avoid overuse of full-text indexing unless absolutely necessary.
Design Specifications and Suggestions of Sharded Clusters
Properly design a Shard key to prevent jumbo chunk when a large number of data uses the same Shard key.
Check your Shards regularly to ensure that data is evenly distributed. Run the sh.status() command to check the sharding status.