Indexing

Indexing

by Killian Perrigon -
Number of replies: 0

Used to find rows w/ specific column values quickly.

Beneficial for really big database with a lot of rows, as MySQL can quickly determine the position to seek to in the middle of the data file w/o having to look at all the data one row at a time. They are generally used to find rows matching a where clause, eliminating rows, and to retrieve rows from other tables when performing joins. Indexes are also invisible to users.

     Topics are usually grouped into a number (the index) which speeds up the where and select statements at the cost of slowing down update and insert statements. Creating an index is super simple. All you need to do is:

     CREATE INDEX ‘indexname’

     ON tablename (columnname)

And if you want to make an index with multiple column names:

     CREATE INDEX ‘indexname’

     ON tablename (column1, column2, column 3…)

You can then chose which order you want it to be sorted in, ascending or descending.