About column order in Postgres
Article explaining why column order can make a difference in postgres
I’ve recently seen some really broad tables (hundreds of columns) in a somewhat inefficiently structured database. Our PostgreSQL support customer complained about strange runtime behavior which could not be easily explained. To help other PostgreSQL users in this same situation, I decided to reveal the secrets of a fairly common performance problem many people don’t understand: Column order and column access.
The first question is: How can we create a table containing many columns? The easiest way is to simply generate the CREATE TABLE statement using generate_series: