pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr@2ndquadrant.com>
To: CK Tan <cktan@vitessedata.com>
To: Colin 't Hart <colin@sharpheart.org>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Subject: Re: Order of columns in query is important?!
Date: Tue, 26 May 2015 12:13:06 +0200
Message-ID: <55644732.8050506@2ndquadrant.com> (raw)
In-Reply-To: <CAJNt7=bn3KwQ0q8yE-3LfTsTMAQSE7kODV=DC0rx33-nHhN5sw@mail.gmail.com>
References: <CAMon-aReV3F4Kn8cN3OhJPe-U1ACkkzzDdOwgtR29yPaA3TmZQ@mail.gmail.com>
	<CAJNt7=bn3KwQ0q8yE-3LfTsTMAQSE7kODV=DC0rx33-nHhN5sw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (8+ messages)  latest in thread

Message-ID: <55644732.8050506@2ndquadrant.com>
Permalink:  ../55644732.8050506@2ndquadrant.com/
Also on:    postgresql.org/message-id/55644732.8050506@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: petr@2ndquadrant.com, cktan@vitessedata.com, colin@sharpheart.org, Langote_Amit_f8@lab.ntt.co.jp
  Subject: Re: Order of columns in query is important?!
  In-Reply-To: <55644732.8050506@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox