I've got a huge InnoDB table(>500 millions rows) which I'd like to partition by hash in order to decrease the index size. I'd like to achieve this with a minimal downtime(e.g 10 minutes is acceptable), what are the possible options?
I was thinking about something as follows:
- create the new partitioned table
- insert into this new table all the data from the old one using "insert ... select ..."
- make server unavailable for clients
- somehow sync changes which happened to the old table during step 2 with the new table
- replace the old table with the new one
- make server available for clients
The main question is what tool can be used in the step 4. The problem is that during step 2 there can be lots of changes to the original table: new inserts, updates, deletes - the sync tool should take all of this into account...
Another possible way, I believe, is:
- setup a replicating slave server
- sync this slave server with master
- switch master/slave roles and re-configure all clients to connect to the new master
- alter table on the previous master
- wait for master/slave synchronization
- switch master/slave roles again, re-configure all clients
Which one would you recommend?