Re: position in DDL of columns used in indexes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew Wakeling <matthew(at)flymine(dot)org>
Cc: Michael Gould <mgould(at)intermodalsoftwaresolutions(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: position in DDL of columns used in indexes
Date: 2009-10-08 15:08:54
Message-ID: 24086.1255014534@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Matthew Wakeling <matthew(at)flymine(dot)org> writes:
> Postgres does not split rows across multiple pages, so this should never
> be a concern. When a row is too big for a page, Postgres will select the
> larger of the columns from the row and compress them. If that fails to
> bring the row size down, then Postgres will select the larger columns and
> remove them to a separate storage area, and leave just the references in
> the actual row. Therefore, the order of columns should not matter.

> Moreover, whether a row is used in an index should not make any
> difference. The index stores the values too, right? Postgres will look up
> in the index, and then fetch the rows, in two separate operations.

Yeah. There can be a small performance advantage to putting the more
frequently accessed columns first (so you don't have to skip over other
columns to get to them). This has nothing directly to do with whether
they are indexed, though.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Joe Uhl 2009-10-08 15:33:00 Partitioned Tables and ORDER BY
Previous Message Matthew Wakeling 2009-10-08 14:36:50 Re: position in DDL of columns used in indexes