Re: Order of columns in query is important?! - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: Order of columns in query is important?!
Date
Msg-id 55644732.8050506@2ndquadrant.com
Whole thread Raw
In response to Re: Order of columns in query is important?!  (CK Tan <cktan@vitessedata.com>)
Responses Re: Order of columns in query is important?!  (CK Tan <cktan@vitessedata.com>)
List pgsql-hackers
On 26/05/15 11:59, CK Tan wrote:
> It has to do with the implementation of slot_getattr, which tries to do
> the deform on-demand lazily.
>
> if you do select a,b,c, the execution would do slot_getattr(1) and
> deform a, and then slot_getattr(2) which reparse the tuple to deform b,
> and finally slot_getattr(3), which parse the tuple yet again to deform c.
>
> Where as if you do select c, b, a, it would do slot_getattr(3) to deform
> c, and in the process deform a and b in one pass. Subsequent calls to
> slot_getattr 1 and 2 would find the attribute ready and available, and
> return it (without parsing the tuple again).
>

If this was the case, changing column order would lead to performance 
increase, not decrease as reported.

My guess would be same as Amits, it's most likely the additional 
projection step.

--  Petr Jelinek                  http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: CK Tan
Date:
Subject: Re: Order of columns in query is important?!
Next
From: CK Tan
Date:
Subject: Re: Order of columns in query is important?!