Mysql – Online schema changes for cloudsql DB

ddlgoogle-cloud-sqlMySQLmysql-5.7online-operations

I'm new to cloudsql for mysql. I have a table with trigger. I need to do some ddl changes on that table. However, I can't take any downtime.

What I have tried so far:

I tried with pt-online-schema-change. Because, it work for our local databases. However, in case of managed cloudsql – it wasn't working. Opened an issue with Percona(PT-1964).

Next, I checked for gh-ost. However, as per their documentation(https://github.com/github/gh-ost/blob/master/doc/requirements-and-limitations.md) -it doesn't support any table with trigger.

Making changes with shared lock option isn't available for me – because we have a replica too.

Does anyone knows any other method/suggeation to make ddl changes online for cloudsql for mysql.

Thanks in advance!

Best Answer

ALTER TABLE t MODIFY COLUMN c ENUM(...) ...

If that is only adding a new option on the end and not going past 255 options, that should be a "schema-only" change that happens instantly. (This was in 5.5, so has been around for 12 years.)

Any other change to the ENUM is likely to require a "copy" of the table (slow).

ALTER TABLE t ADD INDEX (...)

has been efficient (not instant, but did not require copying the table over) since 5.6 (2013).

For other column alterations -- It depends.

That probably does not apply to ADD UNIQUE, and certainly does not apply to any changes to the PRIMARY KEY.

So, based on that info, I would expect Cloud-SQL with 5.7 to handle things "fast". (Sorry, but I have no direct knowledge of that port of MySQL.) I suggest you take it up with the vendor.