hi,
reading this I remembered that I had a performance problem with "IN" too,
but not with a subselect but a list of values.
I had (computed) queries like:
....
and xyz in (1,3,7,234......)
....
with up to 20 such numbers, and found out the queries to be much faster when
I wrote it this way:
....
and xyz >= 1
and xyz <= 234
and xyz in (1,3,7,234......)
....
where 1 is the minimum and 234 is the maximum of all values. The query plan
was much much better in the latter case. Don't know if something minor is
worth optimizing, but I just want let you know.
Best regards,
Mario Weilguni
----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: <depesz@depesz.pl>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, February 18, 2002 3:52 PM
Subject: Re: [GENERAL] IN optimization in 7.2 ?????
> hubert depesz lubaczewski wrote:
> > hi
> > was there optimization for IN (SELECT ... ) usage in 7.2?
> > we just got query which runs 7 times as fast with in than with exists !
> > the query is like select field from table where id in (select ... where
> > fieldx in (... IN (...)));
>
> Not that I know of.
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>