Answer the question
In order to leave comments, you need to log in
A lot of rows in the table per day, should the ID field be int or varchar?
Good afternoon friends, a question about optimization, is there a fundamental difference, what type to use for a table index? For example, about 1000-5000 rows are added to the table per day, int has a limit of 11 characters, varchar has much more, I understand that such a number will not be hammered soon, but still someday it will happen, is it possible to use varchar instead of int and how much it is will it affect performance?
Answer the question
In order to leave comments, you need to log in
At five thousand a day, you will reach 10 million records in about six years. And 214748364 - in 120 years.
int - not 11 characters, but 4 bytes, weighs less, works faster, but you won't notice the difference.
And one more related question, if you will, the int type takes 4 bytes, and bigint 8, as I understand it, that the same number, for example: 999 will take in int (4+4+4 = 12 bytes) and in bigint (8+8+ 8 = 24 bytes)? Is my thought process correct or not?
5000 *1000 = 5 million records in about 3 years, for a normally indexed table, this is not the burden of the word "at all".
If the data is only numeric, then store it always only in numeric form (for integer values int, bigint, etc.). This will save space (in most situations), simplify and speed up indexing, speed up logical (<,>, range entry, etc.) and arithmetic (+,-,*,/,...) operations.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question