开发者

Is accessing a table in Postgres 9 any slower if it has extra unused columns?

开发者 https://www.devze.com 2023-03-07 00:23 出处:网络
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.

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

精彩评论

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