We have a table T which contains a several char(8) columns (implicitly) which under some conditions need to be changed into something like char(64).
We don’t want to waste space, so here is the question:
Is it an expensive operation from the RDBMS computational point of view (extending column data type)? We’d like to have this answered theoretically, no benchmarks. Does database need to rearrange the physical layout of the table because of this?
Yes, quite expensive – every single row in that table must be touched, modified, stored again, and all the non-clustered indices using any of those columns will need to be rebuilt.
Since it’s
CHAR(x), it’s fixed-width – so changing its size results in every single column having to be modified. Also: with the change from 8 to 64 characters, there’s a chance that some pages won’t be able to hold all the rows anymore and page splits with all their overhead will occur.