Re: performance versus order of fields in row

Lists: pgsql-general
From: "D(dot) Stimits" <stimits(at)comcast(dot)net>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: performance versus order of fields in row
Date: 2003-11-25 22:36:29
Message-ID: 3FC3D96D.1020409@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I'm not looking for an exact answer here, but instead something more
"rule of thumb". If I have a table with many fields, and I retrieving
small groups of fields during a SELECT, whereby the groups of fields are
indexed and/or clustered, will I get a faster select in the left-most
fields, or the right-most fields? Or will it not matter? It would be
unusual to SELECT *, I expect to be selecting groups of 4 to 16 fields,
and I am wondering if the most often occuring queries might be improved
by placing them at left or right ends of the table (or if there is any
help at all doing this). The selected groups of fields are unlikely to
be used as a search criterion, but instead as simple read-only, while
other fields determine if the row will be included.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: stimits(at)comcast(dot)net
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: performance versus order of fields in row
Date: 2003-11-25 23:43:52
Message-ID: 9488.1069803832@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"D. Stimits" <stimits(at)comcast(dot)net> writes:
> I'm not looking for an exact answer here, but instead something more
> "rule of thumb". If I have a table with many fields, and I retrieving
> small groups of fields during a SELECT, whereby the groups of fields are
> indexed and/or clustered, will I get a faster select in the left-most
> fields, or the right-most fields? Or will it not matter?

Fields earlier in the table definition (further to the left) are
marginally faster to access than ones further to the right. I doubt it
would be real noticeable unless you had hundreds of fields altogether.

regards, tom lane


From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: stimits(at)comcast(dot)net, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: performance versus order of fields in row
Date: 2003-11-26 03:57:16
Message-ID: 3FC4249C.8050406@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Tom Lane wrote:

>"D. Stimits" <stimits(at)comcast(dot)net> writes:
>
>
>>I'm not looking for an exact answer here, but instead something more
>>"rule of thumb". If I have a table with many fields, and I retrieving
>>small groups of fields during a SELECT, whereby the groups of fields are
>>indexed and/or clustered, will I get a faster select in the left-most
>>fields, or the right-most fields? Or will it not matter?
>>
>>
>
>Fields earlier in the table definition (further to the left) are
>marginally faster to access than ones further to the right. I doubt it
>would be real noticeable unless you had hundreds of fields altogether.
>

Do we still "cache" field offsets for not-nullable-fixed-size columns?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: stimits(at)comcast(dot)net, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: performance versus order of fields in row
Date: 2003-11-26 05:39:27
Message-ID: 11321.1069825167@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Jan Wieck <JanWieck(at)Yahoo(dot)com> writes:
> Tom Lane wrote:
>> Fields earlier in the table definition (further to the left) are
>> marginally faster to access than ones further to the right. I doubt it
>> would be real noticeable unless you had hundreds of fields altogether.

> Do we still "cache" field offsets for not-nullable-fixed-size columns?

Yeah, we do, but I didn't think he wanted to get into that level of
detail ... in any case it's a safe bet that earlier fields are no slower
than later ones.

regards, tom lane