Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)

From: Richard Huxton <dev(at)archonet(dot)com>
To: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Date: 2008-11-11 12:45:19
Message-ID: 49197E5F.9020508@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Sergey Konoplev wrote:
>> Can you post the EXPLAIN ANALYSE output from your NOT IN query?
>>
>
> Seq Scan on table1 (cost=0.00..12648.25 rows=3351 width=0) (actual
> time=0.054..140.596 rows=5000 loops=1)
> Filter: (table1_id <> ALL ('{123456789000, ... plus 1999 ids'::bigint[]))
> Total runtime: 142.303 ms
> (3 rows)
>
> But actual (real) time of running "EXPLAIN SELECT 1 FROM table1 WHERE
> table1_id NOT IN > (...~2000 ids here...);" is
>
> 2000 ids: 34102 ms

I've never heard of EXPLAIN ANALYSE being *faster* than the actual
query, it's usually slower due to all the timing calls. The only thing
it doesn't do is actually send the results over the connection to the
client. In your case, you're not actually selecting any columns, so that
can't be it.

Are you sure there's nothing subtly different about the slow query when
compared with the explain analyse?

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2008-11-11 12:46:20 Re: merge 2 dumps
Previous Message Sergey Konoplev 2008-11-11 12:02:13 Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2008-11-11 13:10:09 Duplicated docs on libpq parameters
Previous Message Ibrar Ahmed 2008-11-11 12:30:49 server crash in to_timestamp function