You inherit a data model that does not use the best datatypes, like using int instead of bigint for a value that can be larger? Don’t wait until the tables grow larger. Here is an example to show how to retype it efficiently. Usually, those operations are done two times:

The DDL that may block the application must be short, with metadata changes only
The DML that modifies data can take longer as long as they are online without impact on the application availability

During the intermediate phase, you have to maintain both versions of the columns. Because YugabyteDB is PostgreSQL compatible with triggers, you may even do that without any change to the application code.

Leave a Reply

Your email address will not be published. Required fields are marked *