Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

Attachment: max_id_count_in_query_test.sh
Description: Bourne shell script

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux