开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜