Side effects of reordering columns in PostgreSQL

Posted by Summer on Stack Overflow See other posts from Stack Overflow or by Summer
Published on 2010-04-08T16:09:32Z Indexed on 2010/04/08 16:13 UTC
Read the original article Hit count: 231

Filed under:

I sometimes re-order the columns in my Postgres DB. Since Postgres can only add columns at the end of tables, I end up re-ordering by adding new columns at the end of the table, setting them equal to existing columns, and then dropping the original columns.

My question is: what does PostgreSQL do with the memory that's freed by dropped columns? Does it automatically re-use the memory, so a single record consumes the same amount of space as it did beforehand? But that would require a re-write of the whole table, so to avoid that, does it just keep a bunch of blank space around in each record?

Thanks!

~S

© Stack Overflow or respective owner

Related posts about postgresql