Re: Best way to "add" columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)cupid(dot)suninternet(dot)com>
Cc: Marten Feldtmann <marten(at)feki(dot)toppoint(dot)de>, Jesse Scott <jscott(at)bmi(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Best way to "add" columns
Date: 2000-05-16 04:56:17
Message-ID: 9809.958452977@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)cupid(dot)suninternet(dot)com> writes:
> Marten Feldtmann wrote:
>> The varable lengths columns should be at the end of the row, therefore
>> it does not seem to be good to add an integer column after a varchar
>> column.

> 1. Is this true? Should variable length column really be at the end
> of a row?

There is some microscopic performance advantage if you put fixed-width
columns before variable-width columns: columns that are at a fixed
offset in the table records don't require scanning through earlier
columns to access. But I'd be surprised if you could actually measure
any difference, unless perhaps on tables with hundreds of columns.

> 2. If so, surly postgres can reorder tham internally so that on disk
> they are in the optimal format.

There are notes in the source code indicating that the original
Berkeley Postgres crew thought about this and decided it wasn't
worth the trouble.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dustin Sallings 2000-05-16 08:41:48 Re: Performance
Previous Message Bruce Momjian 2000-05-16 03:25:26 HTML version of book fixed