Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially.
Creating Indexes:-
create index INDEX_NAME on TABLE_NAME (COLUMN1,COLUMN2,....);
e.g. First we will create a test table and then we will create indexes.
create table test(a int,b int,c int);
create index test_idx1 on test (a,b);
Drop an index:-
DROP INDEX index_name ON TABLE_NAME
e.g. DROP INDEX test_idx1 ON test;
Show Index:-
show index from test;
|
My Blog Title
|