index
For the database to read and write is 9: 1 opening, reading and writing less reading process is IO, the database needs to obtain data from the hard disk, and then sent to the client.
IO is the bottleneck, can not begin to read from the first line of the file has been read the last line of it, good luck to the first line to find the desired data, the last line of bad luck to find.
So there is an index can quickly locate data, which is seen for the previous desc table key field
In addition to these two primary key unique to speed up queries, as well as the role of constraints
The index key role is only to speed up queries
The nature of the index is a data structure that is similar to the book catalog, then find someone directory when looking at page 230, directly turn to page 230 on it.
Index also occupy hard disk space, the equivalent of the book catalog index is used to read the data, once written well, this time to write data, the directory is to change, according to new data added, re-build directory
Index accelerated search, slow down write
But the writing is read relatively little, most bottlenecks are slow queries.
The nature of the index is constantly narrow your search to reduce the number of IO speed up the search.
Disk
The faster the speed, the shorter the time location data, 7200 / min, 120 times per revolution
Index data structure
Is a balanced binary tree, comes the evolution of the B-tree is a B + tree