In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Principle of index
When multiple documents are inserted into a collection, each document, after being persisted by the underlying storage engine, has a location information from which it can be read from the storage engine
MMAPv1: File id+ intra-file offset
WiredTiger: A key generated by WiredTiger when storing documents, through which the corresponding documents can be accessed.
CPU is soaring? Half a day and still no results? If you want to speed up, do you remember the index!!
After the index is established, MongoDB will store an additional index data sorted in ascending order by age field. The index structure is similar to the following. The index is usually stored in a persistent structure similar to btree, so as to ensure that the location information corresponding to a certain age value can be quickly found from the index, and then the corresponding document can be read according to the location information.
Indexing is the organization of documents in order of a field (or fields) so that efficient queries can be made based on that field. The basic role of the index: search + sort
With indexes, at least the following scenarios can be optimized for efficiency:
Query, for example, everyone aged 18.
Update/delete: update or delete the information of all people aged 18, because when updating or deleting, you need to query all qualified documents according to the conditions, so you are essentially optimizing the query.
Sort, sort all people's information by age, if there is no index, you need to scan the document in the full table, and then sort the results of the scan.
DML operations are slower to perform when an index exists (maintaining the index).
MongoDB will generate the_id field for inserted documents by default (if the application itself does not specify this field). The_id is the unique identifier of the document. To ensure that documents can be queried according to the document id, MongoDB will create an index of the_id field for the collection by default.
Characteristics of index
The index is stored in memory (RAM), and you should ensure that the index size does not exceed the memory limit.
If the index size is larger than the memory limit, MongoDB will drop some indexes, which will cause performance degradation.
Index scan type:
Index Overlay: If all required fields are in the index, no additional fields are required to satisfy the index overlay requirement, and no data needs to be loaded from the data page, this is index overlay.
index scan
set scanning
Limitations of index
Each collection is limited to 64 indexes.
The length of an index name cannot exceed 125 characters.
A composite index can have up to 31 fields.
4. All index fields are an array, and indexes cannot be used to overwrite queries.
Regular expressions and non-operators, such as $nin,$not, etc.; arithmetic operators, such as $mod, etc.;$where clauses.
6. The more indexes there are, the worse the write performance, for example, a frequently modified collection whose index reaches 20-30.
Indexing is an IO-intensive operation, especially if your collection is large. This is true of all database systems that support secondary indexing, including MySQL. If you need to index a large collection, consider doing it in the background.
8. If the collection is rarely read, you can not use the index
Type of index
1. Single-field index
2. Composite index
3. Multi-key index
4. Hash index
5. Geographic bitmap index
6. TTL index
7. Full-text index
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.