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 -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general