8 ms·
The article doesn't go into depth on alignment but this is another thing to pay attention to with Postgres column ordering. Postgres uses 8 byte alignment and s
by thom 4y ago
The article doesn't go into depth on alignment but this is another thing to pay attention to with Postgres column ordering. Postgres uses 8 byte alignment and so if you interleave types of different sizes (say a 2-byte smallint between some 8-byte bigints) you may end up with extra padding. This can bloat your tables and potentially reduce performance. It's annoying to have to think about this when in your mind the columns probably have a more meaningful order.
- masklinn 4y ago> Postgres uses 8 byte alignment It doesn’t? Postgres columns have alignment, and that alignment goes from 1 to 8 bytes, but “postgres uses 8 byte alignment” doesn’t really make any sense.
- thom 4y agoApologies for the sloppiness, just trying to be helpful.
- magicalhippo 4y ago> but “postgres uses 8 byte alignment” doesn’t really make any sense Makes perfect sense to me, but it seems it is wrong? At least this page[1] suggests different data types have different alignment. [1]: https://www.enterprisedb.com/postgres-tutorials/data-alignment-postgresql https://www.enterprisedb.com/postgres-tutorials/data-alignme...