5
I have in mind some questions about large volumes of data on MYSQL, concerning the limit of ID. I will give as an example ID guy tinyint
to simplify the explanation. In the example the field tinyint
accepted 127 records.
Assuming you enter 100 new records, this creates Ids of 1 to 100. Eventually the 50 first records will be deleted, so I’ll just have 50 records with Ids of 50 to 100 and allocation for more 27 records, which results in 77 records. That is, we have 77 records only, in a table that should receive up to 127 records.
I know that the MYSQL does not recede to occupy the vacant positions, the question is another. It is not uncommon to have to remove entries, and with this one loses a space in the table.
How would be an efficient way to allocate the actual amount of records without losing the Ids reserved?
Use
bigint
in place ofint
which is the most commonly used, would only increase the time to reach the limit?
Disregard any error of the above calculations :)
In my opinion, your doubt is somewhat mistaken... When you set a field type to a column, you are not setting the amount of record in the table, the table may contain 'N' records. What Voce is setting is the size of the column type, in case the tinyint goes up to 127. Your table would support as many records as you want if this field is not PK. what is not supported is the PK field with duplicate record, thus limiting its table. What you can do is as your bank grows change to int and later bigint....
– Michel Simões
@Michelsimões, when quoting ID, is understood that it is the PK of the table
– MarceloBoni
The answer may include alternatives to
int
and to thebigint
?– Leonel Sanches da Silva
@Gypsy omorrisonmendez, but the use of
bigint
would only increase the 'time' to reach the input limit, correct?– Papa Charlie
@Papacharlie Yes. I will write an answer with another alternative that you haven’t imagined yet.
– Leonel Sanches da Silva
Actually, I was. The @Flaviogranato response was what I was going to answer.
– Leonel Sanches da Silva
@Ciganomorrisonmendez, I made a comment in response. Proceeds the risk of collision?
– Papa Charlie
Not. Look at this.
– Leonel Sanches da Silva