How to identify the columns to be indexed
When to create an index
- When the column is a foreign key
- When the column is used frequently in search conditions or joins
- When the column contains a large number of distinct values
- When the column is updated infrequently
Description
- MySQL automatically creates an index for a primary key.
- An index provides a way for a database management system to locate information more quickly. When it uses an index, the database management system can go directly to a specific row rather than having to search through all the rows until it finds it.
- Indexes speed performance when searching and joining tables.
- You can create composite indexes that include two or more columns. You should use this type of index when the columns in the index are updated infrequently or when the index will cover almost every search condition on the table.
- Because indexes must be updated each time you add, update, or delete a row, you shouldn’t create more indexes than you need.
Back