From: Richard Huxton <dev@archonet.com>
To: pgsql-performance@postgresql.org
Subject: Planner matching constants across tables in a join
Date: Wed, 5 Mar 2003 11:13:14 +0000
Message-ID: <200303051113.14320.dev@archonet.com> (raw)
I know this has been covered on one of the lists in the past, but I'm damned
if I can find the keywords to locate it.
If I join two tables with a comparison to a constant on one, why can't the
planner see that the comparison applies to both tables:
SELECT a.id FROM a JOIN b ON a.id=b.id WHERE a.id=1;
runs much slower than
SELECT a.id FROM a JOIN b ON a.id=b.id WHERE a.id=1 AND b.id=1;
It's not a real problem since it's easy to work around, but I was wondering
what the difficulties are for the planner in seeing that query 1 is the same
as query 2. Note that it doesn't seem related to JOIN forcing the planner's
hand, the same applies just using WHERE a.id=b.id
--
Richard Huxton
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-performance@postgresql.org
Cc: dev@archonet.com
Subject: Re: Planner matching constants across tables in a join
In-Reply-To: <200303051113.14320.dev@archonet.com>
References: <200303051113.14320.dev@archonet.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