Re: [GENERAL] Optimizing IN queries

2008-11-10 Thread Andrus
Try something like "not exists (select null from bilkaib b where b.dokumnr = dok.dokumnr and alusdok = 'LY')". I tried to optimize another similar query but it is still slow. This query has same clause dok.dokumnr IN (869906,869907,869910,869911,869914,869915,869916,869917,869918 ) duplicat

Re: [GENERAL] Optimizing IN queries

2008-11-10 Thread Andrus
Isak, Looks to me like most of the time is spent doing "not in (select a ton of rows from bilkaib)". Try something like "not exists (select null from bilkaib b where b.dokumnr = dok.dokumnr and alusdok = 'LY')". Thank you very much. Query seems to return now immediately. dok.dokumnr is not n

Re: [GENERAL] Optimizing IN queries

2008-11-10 Thread Isak Hansen
On Mon, Nov 10, 2008 at 12:35 PM, Andrus <[EMAIL PROTECTED]> wrote: > explain analyze select count(*)::INTEGER as cnt > from dok >WHERE dokumnr IN > (869906,869907,869910,869911,869914,869915,869916,869917,869918,869921 ) > and > dokumnr NOT IN (SELECT dokumnr FROM bilkaib WHERE > alusd

[GENERAL] Optimizing IN queries

2008-11-10 Thread Andrus
IN queries have large number of int values. Sample below is query which has only 10 values in IN list but takes more than one minute. In real query IN list may contain up to 5000 integers. There are indexes in both dok.dokumnr and bilkaib.dokumnr columns so it should run fast. How to speed up