pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Frank van Vugt <ftm.van.vugt@foxi.nl>
Cc: pgsql-performance@postgresql.org
Subject: Re: why is a constraint not 'pushed down' into a subselect when this subselect is using a 'group by' ??
Date: Tue, 15 Jun 2004 14:04:41 -0400
Message-ID: <3139.1087322681@sss.pgh.pa.us> (raw)
In-Reply-To: <200406151730.40464.ftm.van.vugt@foxi.nl>
References: <200406150849.29470.ftm.van.vugt@foxi.nl>
	<296.1087305799@sss.pgh.pa.us>
	<200406151730.40464.ftm.van.vugt@foxi.nl>

Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> When the 'article.id < 50' constraint is added, it follows that 
> 'foo.article_id < 50' is a constraint as well. Why is this constraint not 
> used to avoid the seqscan on package?

We don't attempt to make every possible inference (and I don't think
you'd like it if we did).  The current code will draw inferences about
transitive equality, for instance given a = b and b = c it will infer
a = c, if all three operators involved are mergejoinable.  But given
a = b and some arbitrary other constraint on b, it won't consider
substituting a into that other constraint.  This example doesn't
persuade me that it would be worth expending the cycles to do so.

Aside from the sheer cost of planning time, there are semantic
pitfalls to consider.  In some datatypes there are values that are
"equal" according to the = operator but are distinguishable by other
operators --- for example, zero and minus zero in IEEE-standard
float arithmetic.  We'd need a great deal of caution in determining
what inferences can be drawn.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <3139.1087322681@sss.pgh.pa.us>
Permalink:  ../3139.1087322681@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3139.1087322681@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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ftm.van.vugt@foxi.nl
  Subject: Re: why is a constraint not 'pushed down' into a subselect when this subselect is using a 'group by' ??
  In-Reply-To: <3139.1087322681@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