Join 5700+ of your peers
Get enriched. Access 1270+ quality tutorials right away on:
Indexes help to speed up the retrieval of data from a MySQL database. When retrieving data, MySQL first checks whether indexes exist. If they exist MySQL will use an index to identify and select exact physical corresponding data rows without scanning the whole table.
In general, it is suggested that you should put indexes on columns you usually use in retrieval such as primary key columns and columns used in join and sorts. Why not index every column? The most significant is that building and maintaining an indexes table’s take time and storage space on database.
Usually you create indexes when creating tables. Any column in creating table statement declared as PRIMARY KEY, KEY, UNIQUE or INDEX will be indexed by MySQL automatically. In addition, you can add indexes to the tables which have data. The statement to create index in MySQL as follows:
Syntax:
<System prompt> CREATE TABLE <Table Name>(
<column1> <datatype>,
<column2> <datatype>,
<columnN> <datatype>,
INDEX(<column1>)
)
Example:
mysql> CREATE TABLE client_details (firstname VARCHAR(50), clientid INT, INDEX (clientid));
What keeps you awake at night?
Do let us know.
We will try our best to deliver tutorials that will help you sleep much better.
The tutorials at have been written by by passionate teachers who have been using open source tools and technologies for years.
Real time images of their development screens are generously used throughout each tutorial.
Download the tutorials to your desktop as PDFs for ready reference whenever you need
Give us your comments or feedback on any of our tutorials.
Your comments help us deliver the best possible training modules.
Is there a specific tutorial you want written? Just Ask.