nosql - Can someone explain in detail how mongodb's index work saves time?
黄舟
黄舟 2017-05-02 09:25:14
0
2
633

MongoDB Index
Indexes can usually greatly improve query efficiency. Without an index, MongoDB must scan each file in the collection when reading data and select those records that meet the query conditions.
The query efficiency of scanning the entire collection is very low. Especially when processing a large amount of data, the query can take dozens of seconds or even minutes, which is very fatal to the performance of the website.

An index is a special data structure. The index is stored in a data collection that is easy to traverse and read. The index is a structure that sorts the values ​​of one or more columns in a database table

The above is the official explanation ()

What I want to know is that after creating an index, how does the database work to find the data when querying? Isn’t it the same as crawling all the databases? ? How to save time and how to work this Baidu for a long time, no one can explain,

To emphasize, I am not asking how to use indexes, I am asking how indexes achieve their purpose and save time

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
阿神

Essentially you can understand it as a 2-point search

给我你的怀抱

Let’s search on Baidu. There are many documents. MongoDB's index is mainly a B-Tree index, and the principle of the B-Tree index of most databases is the same.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template