I have a table in MySQL that I need to rebuild for performance/storage reasons. Is it possible to use pt-online-schema-change with no changes for this purpose or is a change always required? If the former, can I specify this in Liquibase XML?
CodePudding user response:
Yes, I've done this frequently to defragment and recover disk space on a table after a lot of updates or deletes. Any no-op alteration would work the same with pt-online-schema-change, but I use the option --alter=FORCE
because it's mnemonic for ALTER TABLE <name> FORCE
which would be a no-op table restructure if one were not using pt-online-schema-change.
I'm not familiar with Liquibase enough to know how to use it to run a pt-online-schema-change task.
CodePudding user response:
InnoDB tables rarely need OPTIMIZE TABLE
.
Big DELETEs
should be performed in one of several more optimal ways. Some other ways inherently lead to defragmenting as a side effect.