Is accessing a table in Postgres 9 any slower if it has extra unused columns?
Imagine I have a table with two columns, a primary key and some data. Thi开发者_开发百科s table is going to be large and is going to be accessed very frequently.
Now imagine I want to add another piece of data, which is accessed only rarely. Can I safely assume that adding another column to the table is not going to make the common queries any slower if they don’t access the new column?
In theory yes: it'll be slower because less rows will fit per disk page. To read table rows, you'll need to visit more pages.
In practice, null values take 1 bit of room, and varlena types are stored in the extended storage (toast). So it makes little material impact.
精彩评论