pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: heiko.helmbrecht@xclinical.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6723: Exception for correct query
Date: Tue, 10 Jul 2012 00:08:03 -0400
Message-ID: <1768.1341893283@sss.pgh.pa.us> (raw)
In-Reply-To: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org>
References: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org>

heiko.helmbrecht@xclinical.com writes:
> The optimizer is using a where condition for a full table, not to the
> results of a join/subselect result, that's why it is tried to use casts,
> that cannot work on the whole table, here are the easy steps to reproduce
> the problems:

This is not a bug.  The optimizer is allowed to push conditions down
into subqueries; many people would be exceedingly unhappy if it failed
to do that.

There is a workaround you can use if you need it to not work like that,
though: add an "OFFSET 0" to the subquery.  LIMIT and OFFSET clauses
on subqueries serve as optimization fences, because the planner can't
push a WHERE condition down through one for fear of changing the set of
rows selected.

			regards, tom lane



view thread (2+ messages)

Message-ID: <1768.1341893283@sss.pgh.pa.us>
Permalink:  ../1768.1341893283@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1768.1341893283@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, heiko.helmbrecht@xclinical.com
  Subject: Re: BUG #6723: Exception for correct query
  In-Reply-To: <1768.1341893283@sss.pgh.pa.us>
  References: <E1SoD1i-0005T1-Sb@wrigleys.postgresql.org> <1768.1341893283@sss.pgh.pa.us>

* 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