Hi all,
Here is my environment information:
# select version();
version
------------------------------------------------------------------------------------------------
PostgreSQL 8.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
4.2.4 (Ubuntu 4.2.4-1ubuntu3)
(1 row)
I've faced strange parser (or may be planner) behaviour. When I do
"EXPLAIN SELECT 1 FROM table1 WHERE table1_id IN (...~2000 ids
here...);" it works as fast as I expect (50 ms). But when I rewrite it
using NOT IN "EXPLAIN SELECT 1 FROM table1 WHERE table1_id NOT IN
(...~2000 ids here...);" it gets much more slower (34537 ms).
I've done a test case (see attachement) so you can reproduce the
situation (correct PSQL parameter in the begining of the script).
Another thing is that I set my statement_timeout to 20s and it seems
like postgres just ignore this.
Is it a bug and why it happens if not?
Could someone explain what can I do now to make my NOT IN queries work
fast, please?
--
Regards,
Sergey Konoplev
--
PostgreSQL articles in english & russian
http://gray-hemp.blogspot.com/search/label/postgresql/