spanner-schema-diff-tool icon indicating copy to clipboard operation
spanner-schema-diff-tool copied to clipboard

re-order diff output: Create new INDEX and FOREIGN KEYS immediately after the TABLE

Open nielm opened this issue 2 years ago • 0 comments

In the [Spanner update Schema docs](https://cloud.google.com/spanner/docs/schema-updates#large-updates:

It's best practice to create the indexes immediately following the table in the list of DDL statements.

The reason for this is that if any other statements occur between the creation of a table and an index referencing that table, the index creation becomes a more complex operation requiring backfill, and cannot be batched with other statements.

The same applies to foreign key creation -- as the creation of a foreign key requires a backing index on the referencing columns

nielm avatar Jan 29 '24 19:01 nielm