Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: integer Index vs Varchar Index

Tags:

indexing

mysql

Is there any performance problem with index field data type?

Is integer index much faster than varchar index?

like image 805
phpcoder Avatar asked Sep 17 '14 06:09

phpcoder


1 Answers

An integer index is faster than a varchar index because an integer occupies a less space within the database than a varchar. Therefore, it is much faster to find an integer than it is to find a varchar string - because less memory is required to cache the integer index. A smaller data type, means more records can fit into the index blocks. The more records that fit into each index block - the fewer reads are needed to find records.

like image 98
Donal Avatar answered Sep 23 '22 04:09

Donal