Search code examples
google-cloud-platformgoogle-cloud-spanner

Online update spanner schema is extremely slow


Online updating spanner schema takes minutes even for very very small tables (10s of rows).

i.e. - adding/dropping/altering columns, adding tables, etc. This can be quite frustrating for development processes and new version deployments.

Any plans for improvement?

Few more questions:

  1. Anyone knows a 3rd party schema comparison tool for spanner? couldn't find any.
  2. What about data backups? in order to save historical snapshots.

Thanks in advance


Solution

  • Schema Updates: Since Cloud Spanner is a distributed database, it makes sure to update all moving parts of the system which takes the latency as described.

    As a suggestion, you could batch the schema updates. This ensures the lower latencies (nearly equivalent to executing a single schema update) and can be executed using API / gcloud command-line tools.

    Schema Comparison Tool: You could use the getDatabaseDdl API to maintain history of your schema changes and use your tool of choice to diff them.