Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a00d6b23
Commit
a00d6b23
authored
Oct 29, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update for 7.4 --- prefer IN to EXISTS.
parent
a35deb54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
doc/FAQ
doc/FAQ
+10
-8
doc/src/FAQ/FAQ.html
doc/src/FAQ/FAQ.html
+8
-6
No files found.
doc/FAQ
View file @
a00d6b23
Frequently Asked Questions (FAQ) for PostgreSQL
Frequently Asked Questions (FAQ) for PostgreSQL
Last updated:
Fri Oct 10 17:27:02 ED
T 2003
Last updated:
Wed Oct 29 15:19:43 ES
T 2003
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
...
@@ -1031,11 +1031,11 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
...
@@ -1031,11 +1031,11 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
4.22) Why are my subqueries using IN so slow?
4.22) Why are my subqueries using IN so slow?
Currently, we join subqueries to outer queries by sequentiall
y
In versions prior to 7.4, subqueries were joined to outer queries b
y
s
canning the result of the subquery for each row of the outer query.
s
equentially scanning the result of the subquery for each row of the
If the subquery returns only a few rows and the outer query returns
outer query. If the subquery returns only a few rows and the outer
many rows, IN is fastest. To speed up other queries, replace IN with
query returns many rows, IN is fastest. To speed up other queries,
EXISTS:
replace IN with
EXISTS:
SELECT *
SELECT *
FROM tab
FROM tab
WHERE col IN (SELECT subcol FROM subtab);
WHERE col IN (SELECT subcol FROM subtab);
...
@@ -1045,8 +1045,10 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
...
@@ -1045,8 +1045,10 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
FROM tab
FROM tab
WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
For this to be fast, subcol should be an indexed column. This
For this to be fast, subcol should be an indexed column.
preformance problem will be fixed in 7.4.
In version 7.4 and later, IN actually uses the same sophisticated join
techniques as normal queries, and is prefered to using EXISTS.
4.23) How do I perform an outer join?
4.23) How do I perform an outer join?
...
...
doc/src/FAQ/FAQ.html
View file @
a00d6b23
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
alink=
"#0000ff"
>
alink=
"#0000ff"
>
<H1>
Frequently Asked Questions (FAQ) for PostgreSQL
</H1>
<H1>
Frequently Asked Questions (FAQ) for PostgreSQL
</H1>
<P>
Last updated:
Fri Oct 10 17:27:02 ED
T 2003
</P>
<P>
Last updated:
Wed Oct 29 15:19:43 ES
T 2003
</P>
<P>
Current maintainer: Bruce Momjian (
<A
href=
<P>
Current maintainer: Bruce Momjian (
<A
href=
"mailto:pgman@candle.pha.pa.us"
>
pgman@candle.pha.pa.us
</A>
)
<BR>
"mailto:pgman@candle.pha.pa.us"
>
pgman@candle.pha.pa.us
</A>
)
<BR>
...
@@ -1303,10 +1303,10 @@ BYTEA bytea variable-length byte array (null-byte safe)
...
@@ -1303,10 +1303,10 @@ BYTEA bytea variable-length byte array (null-byte safe)
<H4><A
name=
"4.22"
>
4.22
</A>
) Why are my subqueries using
<H4><A
name=
"4.22"
>
4.22
</A>
) Why are my subqueries using
<CODE><SMALL>
IN
</SMALL></CODE>
so slow?
</H4>
<CODE><SMALL>
IN
</SMALL></CODE>
so slow?
</H4>
<P>
Currently, we join subqueries to outer queries by sequentially
<P>
In versions prior to 7.4, subqueries were joined to outer queries
scanning the result of the subquery for each row of the outer
by sequentially scanning the result of the subquery for each row of
query. If the subquery returns only a few rows and the outer query
the outer query. If the subquery returns only a few rows and the outer
returns many rows,
<CODE><SMALL>
IN
</SMALL></CODE>
is fastest. To
query
returns many rows,
<CODE><SMALL>
IN
</SMALL></CODE>
is fastest. To
speed up other queries, replace
<CODE>
IN
</CODE>
with
speed up other queries, replace
<CODE>
IN
</CODE>
with
<CODE>
EXISTS
</CODE>
:
</P>
<CODE>
EXISTS
</CODE>
:
</P>
<PRE>
SELECT *
<PRE>
SELECT *
...
@@ -1320,7 +1320,9 @@ BYTEA bytea variable-length byte array (null-byte safe)
...
@@ -1320,7 +1320,9 @@ BYTEA bytea variable-length byte array (null-byte safe)
</PRE>
</PRE>
For this to be fast,
<CODE>
subcol
</CODE>
should be an indexed column.
For this to be fast,
<CODE>
subcol
</CODE>
should be an indexed column.
This preformance problem will be fixed in 7.4.
<P>
In version 7.4 and later,
<CODE>
IN
</CODE>
actually uses the same
sophisticated join techniques as normal queries, and is prefered
to using
<CODE>
EXISTS
</CODE>
.
<H4><A
name=
"4.23"
>
4.23
</A>
) How do I perform an outer join?
</H4>
<H4><A
name=
"4.23"
>
4.23
</A>
) How do I perform an outer join?
</H4>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment