Re: EXISTS Keyword

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: cnliou(at)eurosport(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: EXISTS Keyword
Date: 2001-10-04 01:59:44
Message-ID: 200110040159.f941xio07679@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Hello!
>
> I vaguely remember that someone said somewhere that
> EXISTS runs faster than IN:
>
> SELECT * FROM table1 where field1 EXISTS (SELECT
> field4 FROM table2)

Move field1 into the subquery and join it to table2. See the FAQ for an
example.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Advid@newgen 2001-10-04 03:47:40 maximum parameters limit to function & manipulating array in plpgsql
Previous Message Stephan Szabo 2001-10-04 01:24:03 Re: SubQuery