If in a Database Table there are no index exist like primary or unique key then when you write a query for search anything from this table of course the search time cost will higher then when you use index in this table.
Cause in without index table the search perform must in entire table if in this table huge amount of record exist then you may find it is slow cause entire table searching.
Where if you use column index then searching cost will minimize from previous time cost. Cause when you use index it it will perform the search operation only on indexed row.
Indexed default row
1) primary key field
2) unique key field
Use of Index :
If you use this kinds of query then it is by default search first
$sql = “select *from table where primary_key_id = 40015”; or $sql = “select *from table where unique_key_name = ‘Jewel'”;
You can also add another indexed column for searching first
Alter a column which are indexed
$sql = “ALTER TABLE table ADD INDEX (‘lastname’) “;
in this query lastname field are indexed altered. Now you can write sql for first search like this
$sql=”select * from table where lastname=’Ahmed'”;
this query will faster. Because The use of index.
Reference Site LInk : http://www.databasejournal.com/features/mysql/article.php/1382791