Here is the performance ranking for primary-keys from fastest to slowest auto-increment-integer
> random-integer
> random-char
> random-varchar
There is enough material regarding why this is so. In short: Data on disk is spread in order of primary key (aka clustering). Hence random is slower than sequential. With sequential indexing when you insert a record, on disk it goes after the last record. But with random indexing, each insert needs to wedge-in between two records. On disk things take time to actually move around.
char
fields are faster than varchar
because chars can be read as is. But to read a varchar data you need to (1) read first byte to get the actual length. (2) read no. of chars equal to now known length.
character (char/varchar) is slower then integer because integer-integer comparison is easy. To compare two character type data, one first needs to convert them into integer, or somehow get them into lexical (dictionary) order. Mostly it is done by matching both strings character-by-character. Thus slooow.