aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-10-10 03:15:19 +0000
committerBruce Momjian <bruce@momjian.us>2002-10-10 03:15:19 +0000
commit52f6918c283ac2a9495aa72e9ae414dffe6cbd74 (patch)
tree1fab1ca5495a9b0c0ce9ac587226b65fa0527531 /doc/src
parent5aa7849e1bdd5d2674a9af78ad09fdd71204b9ac (diff)
downloadpostgresql-52f6918c283ac2a9495aa72e9ae414dffe6cbd74.tar.gz
postgresql-52f6918c283ac2a9495aa72e9ae414dffe6cbd74.zip
Update IN/EXISTS item.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/FAQ/FAQ.html11
1 files changed, 7 insertions, 4 deletions
diff --git a/doc/src/FAQ/FAQ.html b/doc/src/FAQ/FAQ.html
index cad83373cf8..54587662260 100644
--- a/doc/src/FAQ/FAQ.html
+++ b/doc/src/FAQ/FAQ.html
@@ -14,7 +14,7 @@
alink="#0000ff">
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
- <P>Last updated: Mon Sep 30 23:28:35 EDT 2002</P>
+ <P>Last updated: Wed Oct 9 23:14:53 EDT 2002</P>
<P>Current maintainer: Bruce Momjian (<A href=
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
@@ -1282,22 +1282,25 @@ BYTEA bytea variable-length byte array (null-byte safe)
<P>Currently, we join subqueries to outer queries by sequentially
scanning the result of the subquery for each row of the outer
- query. A workaround is to replace <CODE>IN</CODE> with
+ query. If the subquery returns only a few rows and the outer query
+ returns many rows, <CODE><SMALL>IN</SMALL></CODE> is fastest. To
+ speed up other queries, replace <CODE>IN</CODE> with
<CODE>EXISTS</CODE>:</P>
<PRE>
<CODE>SELECT *
FROM tab
- WHERE col1 IN (SELECT col2 FROM TAB2)
+ WHERE col IN (SELECT subcol FROM subtab)
</CODE>
</PRE>
to:
<PRE>
<CODE>SELECT *
FROM tab
- WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 = col2)
+ WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col)
</CODE>
</PRE>
+ For this to be fast, <CODE>subcol</CODE> should be an indexed column.
We hope to fix this limitation in a future release.
<H4><A name="4.23">4.23</A>) How do I perform an outer join?</H4>