19

Is there any performance problem with index field data type?

Is integer index much faster than varchar index?

1 Answer 1

22

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.

Sign up to request clarification or add additional context in comments.

1 Comment

an integer index will do the comparisons in Log(N) while the varchar index will do the comparisons in MLog(N) where M is the number of characters in the index. So that is by default an M fold speed increase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.