Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita00d6b2

Browse files
committed
Update for 7.4 --- prefer IN to EXISTS.
1 parenta35deb5 commita00d6b2

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

‎doc/FAQ

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Frequently Asked Questions (FAQ) for PostgreSQL
33

4-
Last updated:Fri Oct10 17:27:02 EDT 2003
4+
Last updated:Wed Oct29 15:19:43 EST 2003
55

66
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
77

@@ -1031,11 +1031,11 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
10311031

10321032
4.22) Why are my subqueries using IN so slow?
10331033

1034-
Currently, we joinsubqueries to outer queries by sequentially
1035-
scanning the result of the subquery for each row of the outer query.
1036-
If the subquery returns only a few rows and the outer query returns
1037-
many rows, IN is fastest. To speed up other queries, replace IN with
1038-
EXISTS:
1034+
In versions prior to 7.4,subquerieswere joinedto outer queries by
1035+
sequentiallyscanning the result of the subquery for each row of the
1036+
outer query.If the subquery returns only a few rows and the outer
1037+
query returnsmany rows, IN is fastest. To speed up other queries,
1038+
replace IN withEXISTS:
10391039
SELECT *
10401040
FROM tab
10411041
WHERE col IN (SELECT subcol FROM subtab);
@@ -1045,8 +1045,10 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
10451045
FROM tab
10461046
WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
10471047

1048-
For this to be fast, subcol should be an indexed column. This
1049-
preformance problem will be fixed in 7.4.
1048+
For this to be fast, subcol should be an indexed column.
1049+
1050+
In version 7.4 and later, IN actually uses the same sophisticated join
1051+
techniques as normal queries, and is prefered to using EXISTS.
10501052

10511053
4.23) How do I perform an outer join?
10521054

‎doc/src/FAQ/FAQ.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
alink="#0000ff">
1111
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
1212

13-
<P>Last updated:Fri Oct10 17:27:02 EDT 2003</P>
13+
<P>Last updated:Wed Oct29 15:19:43 EST 2003</P>
1414

1515
<P>Current maintainer: Bruce Momjian (<Ahref=
1616
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
@@ -1303,10 +1303,10 @@ <H4><A name="4.21">4.21</A>) How do I create a column that will
13031303
<H4><Aname="4.22">4.22</A>) Why are my subqueries using
13041304
<CODE><SMALL>IN</SMALL></CODE> so slow?</H4>
13051305

1306-
<P>Currently, we joinsubqueries to outer queries by sequentially
1307-
scanning the result of the subquery for each row of the outer
1308-
query. If the subquery returns only a few rows and the outer query
1309-
returns many rows,<CODE><SMALL>IN</SMALL></CODE> is fastest. To
1306+
<P>In versions prior to 7.4,subquerieswere joinedto outer queries
1307+
by sequentiallyscanning the result of the subquery for each row of
1308+
the outerquery. If the subquery returns only a few rows and the outer
1309+
queryreturns many rows,<CODE><SMALL>IN</SMALL></CODE> is fastest. To
13101310
speed up other queries, replace<CODE>IN</CODE> with
13111311
<CODE>EXISTS</CODE>:</P>
13121312
<PRE> SELECT *
@@ -1320,7 +1320,9 @@ <H4><A name="4.22">4.22</A>) Why are my subqueries using
13201320
</PRE>
13211321

13221322
For this to be fast,<CODE>subcol</CODE> should be an indexed column.
1323-
This preformance problem will be fixed in 7.4.
1323+
<P>In version 7.4 and later,<CODE>IN</CODE> actually uses the same
1324+
sophisticated join techniques as normal queries, and is prefered
1325+
to using<CODE>EXISTS</CODE>.
13241326

13251327
<H4><Aname="4.23">4.23</A>) How do I perform an outer join?</H4>
13261328

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp