Skip site navigation (1) Skip section navigation (2)

Re: How far are projections pushed down the execution tree?

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: tmp <skrald(at)amossen(dot)dk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: How far are projections pushed down the execution tree?
Date: 2010-03-02 11:28:51
Message-ID: 4B8CF673.3040502@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-hackers
tmp wrote:
> Consider a table and a query referring to only a subset of the columns
> in that table. How early in the query evaluation is the projection
> carried out?
> 
> Are the columns to be selected filtered out as early as in the very
> access method that reads the table rows from the buffer, or are the
> projection handled later, after the whole row has been fetched by the
> access method?
> 
> Does it depend on the complexity of the query, how far down the three
> that the projection is handled out?

It depends on the kind of plan chosen. In general the planner delays
projection and prefers to do it as high as possible when it can pass a
lower-level tuple to an upper node as is, but if it needs to e.g sort,
projections are done before the sort to avoid carrying unnecessary data
through the sort.

EXPLAIN VERBOSE (in 8.4 upwards) shows the columns that are being output
from node, you can use that to examine the behavior.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

In response to

Responses

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2010-03-02 11:54:52
Subject: Re: Streaming replication and pg_xlogfile_name()
Previous:From: Asher HoskinsDate: 2010-03-02 10:47:03
Subject: to_timestamp() and quarters

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group