Column order performance - Mailing list pgsql-performance

From Bill Montgomery
Subject Column order performance
Date
Msg-id 4118D008.1070606@lulu.com
Whole thread Raw
Responses Re: Column order performance
List pgsql-performance
Does the order of columns of varying size have any effect on
SELECT/INSERT/UPDATE/and/or/DELETE performance? Take the example where
an integer primary key is listed first in the table and alternatively
listed after some large varchar or text columns? For example, is this
different performance-wise:

CREATE TABLE foo
(
    foo_id serial,
    foo_data varchar(8000),
    primary key (foo_id)
);

from this?

CREATE TABLE bar
(
    bar_data varchar(8000),
    bar_id serial,
    primary key (bar_id)
);

My suspicion is it would never make a difference since the index will be
searched when querying "WHERE [foo|bar]_id=?" (as long as the planner
decides to use the index).

What about a case where a sequential scan _must_ be performed? Could the
order of columns make a difference in the number of pages read/written
if there is a mix of small and large columns?

Thanks for your help.

Best Regards,

Bill Montgomery

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: insert waits for delete with trigger
Next
From: Litao Wu
Date:
Subject: Re: insert waits for delete with trigger