• 0

MySQL Change primary on a large table


Question

Hi,

I need some advice and help, I need to change the primary key ID to auto increment on a table which is 19.4GB in size with approximately 150 million entries.

PQvoBf1.png

Apparently running Alter table is going to take hours and hours to complete which I can understand.

The table has huge amounts of data in it

q3oRu6O.png

What would be the fastest way to update the items table?

5 answers to this question

Recommended Posts

  • 0

yeah i suggest coping this to a non production server for some testing....

On the test machine:

I would backup the table and rename it, then create the new table with the old name.

then do insert or something like that... I've heard its MUCH quicker to delete then import.... an to alter the records.

with that amount of data i would defo do some testing off production... as i know some takes can take 24hr + if bad sql is used...

This topic is now closed to further replies.