pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tambet Matiisen <t.matiisen@aprote.ee>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: ch@rodos.fzk.de
Cc: pgsql-sql@postgresql.org
Subject: Re: How to force subquery scan?
Date: Thu, 17 Mar 2005 10:39:43 +0200
Message-ID: <A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.com> (raw)



> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
> Sent: Wednesday, March 16, 2005 5:42 PM
> To: Tambet Matiisen
> Cc: ch@rodos.fzk.de; pgsql-sql@postgresql.org
> Subject: Re: [SQL] How to force subquery scan? 
> 
> 
> "Tambet Matiisen" <t.matiisen@aprote.ee> writes:
> > It seems that subquery scan is only used, when the query can not be 
> > translated into single flat query. Which is mostly good, I assume.
> 
> The planner thinks so anyway ;-)
> 
> If you're desperate you can put in an optimization fence, for 
> instance LIMIT or OFFSET.
> 
> 	SELECT * FROM (SELECT ... OFFSET 0) ss;
> 
> In principle the planner could figure out that this offset is 
> a no-op, throw it away, and then flatten the query.  But it 
> doesn't at the moment, and I doubt we'll teach it to do so in 
> the future.
> 
> 			regards, tom lane
> 

Thanks, that did the trick. It was a bit more strict than expected,
because WHERE of the outer query is not optimized into subquery. But
considering the semantics of OFFSET that seems reasonable and I can work
around it for now.

  Tambet



view thread (5+ messages)

Message-ID: <A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.com>
Permalink:  ../A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.com/
Also on:    postgresql.org/message-id/A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: t.matiisen@aprote.ee, tgl@sss.pgh.pa.us, ch@rodos.fzk.de
  Subject: Re: How to force subquery scan?
  In-Reply-To: <A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.com>
  References: <A66A11DBF5525341AEF6B8DE39CDE77008805A@black.aprote.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