Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case) - Mailing list pgsql-general

From Richard Huxton
Subject Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Date
Msg-id 49197E5F.9020508@archonet.com
Whole thread Raw
In response to Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)  ("Sergey Konoplev" <gray.ru@gmail.com>)
Responses Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
List pgsql-general
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

pgsql-general by date:

Previous
From: "Sergey Konoplev"
Date:
Subject: Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Next
From: Richard Huxton
Date:
Subject: Re: merge 2 dumps