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

Re: Outer joins and equivalence

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Outer joins and equivalence
Date: 2008-06-02 19:47:11
Message-ID: 1212436031.4120.400.camel@ebony.site (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-performance
On Mon, 2008-06-02 at 18:10 +0100, Simon Riggs wrote:
> On Tue, 2008-05-27 at 17:43 -0400, Tom Lane wrote:
> > Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > > I have a complex query where making a small change to the SQL increases
> > > run-time by > 1000 times.
> > 
> > > The first SQL statement is of the form
> > 
> > > A JOIN B ON (a.id = b.id) LEFT JOIN C ON (a.id = c.id) 
> > 
> > > and the second is like this
> > 
> > > A JOIN B ON (a.id = b.id) LEFT JOIN C ON (b.id = c.id)
> > 
> > > the only difference is the substitution of a -> b
> > 
> > Please provide an actual test case.
> 
> Getting closer, but still not able to produce a moveable test case.

I've got a test case which shows something related and weird, though not
the exact case.

The queries shown here have significantly different costs, depending
upon whether we use tables a or b in the query. Since a and b are
equivalent this result isn't expected at all.

I suspect the plan variation in the original post is somehow cost
related and we are unlikely to discover the exact plan.

-- 
 Simon Riggs           www.2ndQuadrant.com
 PostgreSQL Training, Services and Support

Attachment: q.sql
Description: text/x-sql (1.4 KB)

In response to

Responses

pgsql-performance by date

Next:From: JustinDate: 2008-06-02 21:43:09
Subject: getting estimated cost to agree with actual
Previous:From: Simon RiggsDate: 2008-06-02 17:10:44
Subject: Re: Outer joins and equivalence

pgsql-hackers by date

Next:From: Shane AmblerDate: 2008-06-02 19:50:32
Subject: Re: Case-Insensitve Text Comparison
Previous:From: James William PyeDate: 2008-06-02 18:56:28
Subject: Re: Proposal: new function array_init

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