phpcoder
phpcoder

Reputation: 225

MySQL: integer Index vs Varchar Index

Is there any performance problem with index field data type?

Is integer index much faster than varchar index?

Upvotes: 18

Views: 8032

Answers (1)

Donal
Donal

Reputation: 32803

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.

Upvotes: 21

Related Questions