Slow alter

When the database server uses the slow alter algorithm to process an ALTER TABLE statement, the table can be unavailable to other users for a long period of time.

The table might be unavailable because the database server:
  • Locks the table in exclusive mode for the duration of the ALTER TABLE operation
  • Makes a copy of the table in order to convert the table to the new definition
  • Converts the data rows during the ALTER TABLE operation
  • Can treat the ALTER TABLE statement as a long transaction and abort it if the LTXHWM threshold is exceeded

Because the database server makes a copy of the table to convert the table to the new definition, a slow alter operation requires space at least twice the size of the original table plus log space.

The database server uses the slow alter algorithm when the ALTER TABLE statement makes column changes that it cannot perform in place:
  • Adding or dropping a column created with the ROWIDS keyword
  • Adding or dropping a column created with the REPLCHECK keyword
  • Dropping a column of the TEXT or BYTE data type
  • Modifying a SMALLINT column to SERIAL, SERIAL8, or BIGSERIAL
  • Converting an INT column to SERIAL, SERIAL8, or BIGSERIAL
  • Modifying the data type of a column so that some possible values of the old data type cannot be converted to the new data type (For example, if you modify a column of data type INTEGER to CHAR(n), the database server uses the slow alter algorithm if the value of n is less than 11. An INTEGER requires 10 characters plus one for the minus sign for the lowest possible negative values.)
  • Modifying the data type of a fragmentation column in a way that value conversion might cause rows to move to another fragment
  • Adding, dropping or modifying any column when the table contains user-defined data types, smart large objects, or LVARCHAR, SET, MULTISET, ROW, or COLLECTION data types
  • Modifying the original size or reserve specifications of VARCHAR or NVARCHAR columns
  • Adding ERKEY shadow columns

Copyright© 2019 HCL Technologies Limited