Feed on
Subscription

MySQL index is analysed and optimize

What is index?


The record that index uses apace to search those to have specific value,The form that all MySQL index cultivates with B- is saved.If do not have index,The MySQL when executive inquiry must begin to scan from the first record all records of whole watch,Till find the record that accords with a requirement.The record amount of face of exterior and interior is more,The price of this operation is higher.If serve as the file that searchs a condition to went up to had been founded,index,MySQL need not scan the seat that any records can get quickly the target records a place.If the watch has 1000 records,Search a record to want to be recorded than ordinal scanning at least through index 100 times faster.

Assume we founded a watch that the name is People:





CREATE TABLE People (Peopleid SMALLINT NOT NULL, name CHAR(50) NOT NULL);


Next,We are worth 1000 different Name completely randomly insert People to express.The one fraction that next graphs showed to People expresses place data file:




Can see,The order that does not have any making clear in row of the Name in data file.If we founded the index that Name lists,MySQL will be listed in Name of the sort in index:





To index each medium,MySQL interiorly saves what actual record is in the position in file of a data for it " pressing with a finger " .Because of this,If we want to search Name to be equal to " Mike " the Peopleid of the record (SQL command is " SELECT Peopleid FROM People WHERE Name='Mike'; " ) ,MySQL can be searched in the index of Name " Mike " value,The corresponding travel in turning to data file directly next,The Peopleid that returns this well and truly to go (999) .In this process,MySQL needs to handle a travel to be able to return a result only.If do not have " Name " the index of the row,MySQL wants all records in scanning data file,Namely 1000 records!Apparent,The record amount that needs MySQL processing is less,Criterion the rate of its task that finish is rapidder.

[1] [2] [3] [4] issues one page

Related:

    收藏到网摘:

    Submit: