In one of my projects, the current implementation of a log system uses a mysql table. The applications released to customers write some log information to the table on a daily basis. There is a script on our server to automatically remove all logs that are more than 60 days old. The problem is that the primary id keeps growing and some time in the future, it will outgrow the limit. The id currently is set to int auto_increment. So what’s the best solution for this problem. I am no expert in database and your help is highly appreciated. I tried to search on Stack Overflow but could not find answer for my case.
Should I change int to bigint? How do I do that without interrupting the db’s normal operation? I want to avoid any down time. But even with bigint, the id will reach the limit one day. It looks like I am just delaying the problem. Is there a good solution? Can I configure the db so it can re-use ids that become available after the script removes old data?
Try not to delete the table, but archive the content after 60 days i.e. delete from the main table and insert into the archived table. For the second issue, if the value of the PK is increasing like hell try the type ‘bigint’