mysqldatabasesql-types

Are double integers more efficient as database IDs than string codes?


This question is relevant to MySQL databases or tables that exceed 1 million rows.

As each row shall have a unique ID (or code) which is later used to create relationships between several tables, is it more efficient to use a double integer ID such as "1456156148489418189" instead of string code such as "ds156b1dsb4ds8b4sd6b14s864ea".

Does for example JOIN or even SELECT have an easier time searching for a double integer than for a string in a table of more than million rows? If so is there some correlation such as 40 digit double integer is 50% more efficient as a UID than using 20 character string?


Solution

  • Use auto increment instead of string if your id is just for primary key not for shown in user interface