pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Haas <robertmhaas@gmail.com>
To: Achilleas Mantzios <achill@matrix.gatewaynet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: "NOT IN" substantially slower in 9.0.2 than 8.3.13 - NOT EXISTS runs fast in both 8.3.13 and 9.0.2
Date: Fri, 21 Jan 2011 12:09:12 -0500
Message-ID: <AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@mail.gmail.com> (raw)
In-Reply-To: <201101200905.26400.achill@matrix.gatewaynet.com>
References: <955263366.48014741295283147090.JavaMail.root@ucimail4.uci.cu>
	<201101191110.05268.achill@matrix.gatewaynet.com>
	<21792.1295458016@sss.pgh.pa.us>
	<201101200905.26400.achill@matrix.gatewaynet.com>

On Thu, Jan 20, 2011 at 2:05 AM, Achilleas Mantzios
<achill@matrix.gatewaynet.com> wrote:
>                                                     ->  Hash Semi Join  (cost=2768.00..5671.67 rows=1 width=12) (actual time=39.249..81.025 rows=1876 loops=1)
>                                                           Hash Cond: (msold.marinerid = msold2.marinerid)
>                                                           Join Filter: ((msold2.id <> msold.id) AND (msold2.starttime < msold.starttime) AND ((msold.starttime - msold2.endtime) <= '1 year 6 mons'::interval))
>                                                           ->  Seq Scan on marinerstates msold  (cost=0.00..2889.32 rows=4590 width=20) (actual time=0.003..33.964 rows=2625 loops=1)
>                                                                 Filter: (((state)::text = 'Active'::text) AND ((starttime)::date <= '2007-01-11'::date) AND ((COALESCE(endtime, now()))::date >= '2006-07-15'::date))
>                                                           ->  Hash  (cost=2251.66..2251.66 rows=41307 width=24) (actual time=39.156..39.156 rows=41250 loops=1)
>                                                                 Buckets: 8192  Batches: 1  Memory Usage: 2246kB
>                                                                 ->  Seq Scan on marinerstates msold2  (cost=0.00..2251.66 rows=41307 width=24) (actual time=0.002..24.552 rows=41250 loops=1)
>                                                                       Filter: ((state)::text = 'Active'::text)

Looks like the bad selectivity estimate there is what's killing it.
Not sure I completely understand why 9.0.2 is coming up with such a
bad estimate, though.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



view thread (16+ messages)  latest in thread

Message-ID: <AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@mail.gmail.com>
Permalink:  ../AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@mail.gmail.com/
Also on:    postgresql.org/message-id/AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@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: robertmhaas@gmail.com, achill@matrix.gatewaynet.com
  Subject: Re: "NOT IN" substantially slower in 9.0.2 than 8.3.13 - NOT EXISTS runs fast in both 8.3.13 and 9.0.2
  In-Reply-To: <AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@mail.gmail.com>
  References: <955263366.48014741295283147090.JavaMail.root@ucimail4.uci.cu> <201101191110.05268.achill@matrix.gatewaynet.com> <21792.1295458016@sss.pgh.pa.us> <201101200905.26400.achill@matrix.gatewaynet.com> <AANLkTimeC41oJ34yzPPf3wc_qQ_mKT_=krCcD7OMEYsc@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