pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steven Flatt <steven.flatt@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Steinar H. Gunderson <sgunderson@bigfoot.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: performance drop on 8.2.4, reverting to 8.1.4
Date: Tue, 5 Jun 2007 17:30:14 -0400
Message-ID: <357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.com> (raw)
In-Reply-To: <28604.1179503689@sss.pgh.pa.us>
References: <20070518104646.GA13811@uio.no>
	<008201c7993c$76c88a10$653e10ac@ilgvaio>
	<20070518111455.GA13978@uio.no>
	<28604.1179503689@sss.pgh.pa.us>

On 5/18/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>
> Yeah.  8.2 is estimating that the "nodeid IS NULL" condition will
> discard all or nearly all the rows, presumably because there aren't any
> null nodeid's in the underlying table --- it fails to consider that the
> LEFT JOIN may inject some nulls.  8.1 was not any brighter; the reason
> it gets a different estimate is that it doesn't distinguish left-join
> and WHERE clauses at all, but assumes that the result of the left join
> can't have fewer rows than its left input, even after applying the
> filter condition.  In this particular scenario that happens to be a
> better estimate.  So even though 8.2 is smarter, and there is no bug
> here that wasn't in 8.1 too, it's getting a worse estimate leading to
> a worse plan.
>
> This is a sufficiently common idiom that I think it's a must-fix
> problem.  Not sure about details yet, but it seems somehow the
> selectivity estimator had better start accounting for
> outer-join-injected NULLs.
>
This problem is causing us a bit of grief as we plan to move from 8.1.4 to
8.2.4.  We have many (on the order of a hundred) queries that are of the
form:

(A) LEFT JOIN (B) ON col WHERE B.col IS NULL

These queries are much slower on 8.2 than on 8.1 for what looks like the
reason outlined above.  I have rewritten a few key queries to be of the
equivalent form:

(A) WHERE col NOT IN (SELECT col FROM (B))

which has resulted in a dramatic improvement.  I'm really hoping that I'm
not going to need to re-write every single one of our queries that are of
the first form above.  Is there any estimation as to if/when the fix will
become available?  I'm hoping this isn't going to be a showstopper in us
moving to 8.2.

Thanks,
Steve

view thread (24+ messages)  latest in thread

Message-ID: <357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.com>
Permalink:  ../357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.com/
Also on:    postgresql.org/message-id/357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.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-performance@postgresql.org
  Cc: steven.flatt@gmail.com, tgl@sss.pgh.pa.us, sgunderson@bigfoot.com
  Subject: Re: performance drop on 8.2.4, reverting to 8.1.4
  In-Reply-To: <357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.com>
  References: <20070518104646.GA13811@uio.no> <008201c7993c$76c88a10$653e10ac@ilgvaio> <20070518111455.GA13978@uio.no> <28604.1179503689@sss.pgh.pa.us> <357fa7590706051430h5db6760dx9d4a46c7a8a36205@mail.gmail.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