Timwi
Timwi

Reputation: 66584

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. This 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?

Upvotes: 1

Views: 105

Answers (1)

Denis de Bernardy
Denis de Bernardy

Reputation: 78503

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.

Upvotes: 1

Related Questions