Re: NOT IN query takes forever

From: Marius Andreiana <mandreiana(at)rdslink(dot)ro>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: NOT IN query takes forever
Date: 2004-08-03 16:02:42
Message-ID: 1091548963.6915.2.camel@marte.biciclete.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

On Tue, 2004-08-03 at 08:05 -0400, Merlin Moncure wrote:
> > Trying to run this query:
> > EXPLAIN ANALYSE
> > select * FROM trans
> > WHERE query_id NOT IN (select query_id FROM query)
> >
> > but it will remain like that forever (cancelled after 30 min).
>
> explain analyze actually runs the query to do timings. Just run explain
> and see what you come up with. More than likely there is a nestloop in
> there which is causing the long query time.
>
> Try bumping up shared buffers some and sort mem as much as you safely
> can.
Thank you, that did it!

With
shared_buffers = 3000 # min 16, at least max_connections*2, 8KB each
sort_mem = 128000 # min 64, size in KB

it takes <3 seconds (my hardware is not server-class).

--
Marius Andreiana
Galuna - Solutii Linux in Romania
http://www.galuna.ro

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2004-08-03 16:18:42 Re: Casting timestamp with time zone to varchar automatically
Previous Message Greg Stark 2004-08-03 15:05:28 Trying to use GIST indexes again

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2004-08-03 16:10:04 Re: NOT IN query takes forever
Previous Message Gaetano Mendola 2004-08-03 15:54:44 Re: pg_autovacuum parameters