MySql--index


Index
Note
Be aware that building too many indexes will affect the speed of updates and inserts, as it requires updating every index file equally.
For a table that needs to be updated and inserted frequently, there is no need to create a separate index for a rarely used where clause.
For a relatively small table, the sorting overhead is not very large, and there is no need to create another index.

Indexing takes up disk space


 The main problem that the index solves

-- When the data is very large, and the data does not need to be modified frequently, in order to speed up the query, we will use the index  to create a table create table test_index(title varchar(10)); --Test step 1. Turn on runtime monitoring : set profiling=1; 2. Find the 10,000th data ha-99999 select * from test_index where title='ha-99999'; 3. Check the execution time: show profiles; 4. Create an index for the title column of the table title_index : create index index name on table name (field name) create index my_index on test_index(title); 5. Execute the query: select * from test_index where title='ha-99999'; 6. Check the execution time again show profiles; --View index-- show index from table name; show index from test_index; --delete index ---drop index index name on table name;



























drop index my_index on test_index;


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326006464&siteId=291194637