1010alink ="#0000ff ">
1111< H1 > Frequently Asked Questions (FAQ) for PostgreSQL</ H1 >
1212
13- < P > Last updated: Sat Jan 29 23:15:42 EST 2005</ P >
13+ < P > Last updated: Sat Jan 29 23:20:03 EST 2005</ P >
1414
1515< P > Current maintainer: Bruce Momjian (< A href =
1616 "mailto:pgman@candle.pha.pa.us "> pgman@candle.pha.pa.us</ A > )< BR >
@@ -114,16 +114,14 @@ <H2 align="center">Operational Questions</H2>
114114< I > "invalid large obj descriptor"</ I > ?< BR >
115115< A href ="#4.17 "> 4.17</ A > ) How do I create a column that will
116116 default to the current time?< BR >
117- < A href ="#4.18 "> 4.18</ A > ) Why are my subqueries using
118- < CODE > < SMALL > IN</ SMALL > </ CODE > so slow?< BR >
119- < A href ="#4.19 "> 4.19</ A > ) How do I perform an outer join?< BR >
120- < A href ="#4.20 "> 4.20</ A > ) How do I perform queries using multiple
117+ < A href ="#4.18 "> 4.18</ A > ) How do I perform an outer join?< BR >
118+ < A href ="#4.19 "> 4.19</ A > ) How do I perform queries using multiple
121119 databases?< BR >
122- < A href ="#4.21 "> 4.21 </ A > ) How do I return multiple rows or columns
120+ < A href ="#4.20 "> 4.20 </ A > ) How do I return multiple rows or columns
123121 from a function?< BR >
124- < A href ="#4.22 "> 4.22 </ A > ) Why can't I reliably create/drop
122+ < A href ="#4.21 "> 4.21 </ A > ) Why can't I reliably create/drop
125123 temporary tables in PL/PgSQL functions?< BR >
126- < A href ="#4.23 "> 4.23 </ A > ) What encryption options are available?< BR >
124+ < A href ="#4.22 "> 4.22 </ A > ) What encryption options are available?< BR >
127125
128126
129127< H2 align ="center "> Extending PostgreSQL</ H2 >
@@ -1155,31 +1153,7 @@ <H4><A name="4.17">4.17</A>) How do I create a column that will
11551153</ CODE >
11561154</ PRE >
11571155
1158- < H4 > < A name ="4.18 "> 4.18</ A > ) Why are my subqueries using
1159- < CODE > < SMALL > IN</ SMALL > </ CODE > so slow?</ H4 >
1160-
1161- < P > In versions prior to 7.4, subqueries were joined to outer queries
1162- by sequentially scanning the result of the subquery for each row of
1163- the outer query. If the subquery returns only a few rows and the outer
1164- query returns many rows,< CODE > < SMALL > IN</ SMALL > </ CODE > is fastest. To
1165- speed up other queries, replace< CODE > IN</ CODE > with
1166- < CODE > EXISTS</ CODE > :</ P >
1167- < PRE > SELECT *
1168- FROM tab
1169- WHERE col IN (SELECT subcol FROM subtab);
1170- </ PRE >
1171- to:
1172- < PRE > SELECT *
1173- FROM tab
1174- WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
1175- </ PRE >
1176-
1177- For this to be fast,< CODE > subcol</ CODE > should be an indexed column.
1178- < P > In version 7.4 and later,< CODE > IN</ CODE > actually uses the same
1179- sophisticated join techniques as normal queries, and is prefered
1180- to using< CODE > EXISTS</ CODE > .
1181-
1182- < H4 > < A name ="4.19 "> 4.19</ A > ) How do I perform an outer join?</ H4 >
1156+ < H4 > < A name ="4.18 "> 4.18</ A > ) How do I perform an outer join?</ H4 >
11831157
11841158< P > PostgreSQL supports outer joins using the SQL standard syntax.
11851159 Here are two examples:</ P >
@@ -1219,7 +1193,7 @@ <H4><A name="4.19">4.19</A>) How do I perform an outer join?</H4>
12191193 ORDER BY col1
12201194</ PRE >
12211195
1222- < H4 > < A name ="4.20 "> 4.20 </ A > ) How do I perform queries using
1196+ < H4 > < A name ="4.19 "> 4.19 </ A > ) How do I perform queries using
12231197 multiple databases?</ H4 >
12241198
12251199< P > There is no way to query a database other than the current one.
@@ -1231,15 +1205,15 @@ <H4><A name="4.20">4.20</A>) How do I perform queries using
12311205 connections to different databases and merge the results on the
12321206 client side.</ P >
12331207
1234- < H4 > < A name ="4.21 "> 4.21 </ A > ) How do I return multiple rows or
1208+ < H4 > < A name ="4.20 "> 4.20 </ A > ) How do I return multiple rows or
12351209 columns from a function?</ H4 >
12361210
12371211< P > In 7.3, you can easily return multiple rows or columns from a
12381212 function,
12391213< a href ="http://techdocs.postgresql.org/guides/SetReturningFunctions ">
12401214 http://techdocs.postgresql.org/guides/SetReturningFunctions</ a > .
12411215
1242- < H4 > < A name ="4.22 "> 4.22 </ A > ) Why can't I reliably create/drop
1216+ < H4 > < A name ="4.21 "> 4.21 </ A > ) Why can't I reliably create/drop
12431217 temporary tables in PL/PgSQL functions?</ H4 >
12441218< P > PL/PgSQL caches function contents, and an unfortunate side effect
12451219 is that if a PL/PgSQL function accesses a temporary table, and that
@@ -1249,7 +1223,7 @@ <H4><A name="4.22">4.22</A>) Why can't I reliably create/drop
12491223< SMALL > EXECUTE</ SMALL > for temporary table access in PL/PgSQL. This
12501224 will cause the query to be reparsed every time.</ P >
12511225
1252- < H4 > < A name ="4.23 "> 4.23 </ A > ) What encryption options are available?
1226+ < H4 > < A name ="4.22 "> 4.22 </ A > ) What encryption options are available?
12531227</ H4 >
12541228< UL >
12551229< LI > < I > contrib/pgcrypto</ I > contains many encryption functions for