Re: position in DDL of columns used in indexes - Mailing list pgsql-performance

From Tom Lane
Subject Re: position in DDL of columns used in indexes
Date
Msg-id 24086.1255014534@sss.pgh.pa.us
Whole thread Raw
In response to Re: position in DDL of columns used in indexes  (Matthew Wakeling <matthew@flymine.org>)
List pgsql-performance
Matthew Wakeling <matthew@flymine.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

pgsql-performance by date:

Previous
From: Matthew Wakeling
Date:
Subject: Re: position in DDL of columns used in indexes
Next
From: Joe Uhl
Date:
Subject: Partitioned Tables and ORDER BY