Commit 25deba31 authored by Bruce Momjian's avatar Bruce Momjian

Update LIMIT/FETCH FAQ item.

parent 0a92c58b
Frequently Asked Questions (FAQ) for PostgreSQL Frequently Asked Questions (FAQ) for PostgreSQL
Last updated: Mon Jan 31 19:18:44 EST 2005 Last updated: Mon Jan 31 20:35:58 EST 2005
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
...@@ -445,17 +445,13 @@ ...@@ -445,17 +445,13 @@
PostgreSQL releases? PostgreSQL releases?
The PostgreSQL team makes only small changes between minor releases, The PostgreSQL team makes only small changes between minor releases,
so upgrading from 7.2 to 7.2.1 does not require a dump and restore. so upgrading from 7.4 to 7.4.1 does not require a dump and restore.
However, major releases (e.g. from 7.2 to 7.3) often change the However, major releases (e.g. from 7.3 to 7.4) often change the
internal format of system tables and data files. These changes are internal format of system tables and data files. These changes are
often complex, so we don't maintain backward compatability for data often complex, so we don't maintain backward compatibility for data
files. A dump outputs data in a generic format that can then be loaded files. A dump outputs data in a generic format that can then be loaded
in using the new internal format. in using the new internal format.
In releases where the on-disk format does not change, the pg_upgrade
script can be used to upgrade without a dump/restore. The release
notes mention whether pg_upgrade is available for the release.
3.8) What computer hardware should I use? 3.8) What computer hardware should I use?
Because PC hardware is mostly compatible, people tend to believe that Because PC hardware is mostly compatible, people tend to believe that
...@@ -471,13 +467,10 @@ ...@@ -471,13 +467,10 @@
4.1) How do I SELECT only the first few rows of a query? A random row? 4.1) How do I SELECT only the first few rows of a query? A random row?
See the FETCH manual page, or use SELECT ... LIMIT.... To retrieve only a few rows, if you know at the number of rows needed
at the time of the SELECT use LIMIT . If an index matches the ORDER BY
The entire query may have to be evaluated, even if you only want the it is possible the entire query does not have to be executed. If you
first few rows. Consider using a query that has an ORDER BY. If there don't know the number of rows at SELECT time, use a cursor and FETCH.
is an index that matches the ORDER BY, PostgreSQL may be able to
evaluate only the first few records requested, or the entire query may
have to be evaluated until the desired rows have been generated.
To SELECT a random row, use: To SELECT a random row, use:
SELECT col SELECT col
......
...@@ -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: Mon Jan 31 19:18:44 EST 2005</P> <P>Last updated: Mon Jan 31 20:35:58 EST 2005</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>) "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)
...@@ -590,18 +590,13 @@ ...@@ -590,18 +590,13 @@
to upgrade between major PostgreSQL releases?</H4> to upgrade between major PostgreSQL releases?</H4>
<P>The PostgreSQL team makes only small changes between minor releases, <P>The PostgreSQL team makes only small changes between minor releases,
so upgrading from 7.2 to 7.2.1 does not require a dump and restore. so upgrading from 7.4 to 7.4.1 does not require a dump and restore.
However, major releases (e.g. from 7.2 to 7.3) often change the internal However, major releases (e.g. from 7.3 to 7.4) often change the internal
format of system tables and data files. These changes are often complex, format of system tables and data files. These changes are often complex,
so we don't maintain backward compatability for data files. A dump outputs so we don't maintain backward compatibility for data files. A dump outputs
data in a generic format that can then be loaded in using the new internal data in a generic format that can then be loaded in using the new internal
format.</P> format.</P>
<P>In releases where the on-disk format does not change, the
<I>pg_upgrade</I> script can be used to upgrade without a dump/restore.
The release notes mention whether <I>pg_upgrade</I> is available for the
release.</P>
<H4><A name="3.8">3.8</A>) What computer hardware should I use?</H4> <H4><A name="3.8">3.8</A>) What computer hardware should I use?</H4>
<P>Because PC hardware is mostly compatible, people tend to believe that <P>Because PC hardware is mostly compatible, people tend to believe that
...@@ -619,15 +614,13 @@ ...@@ -619,15 +614,13 @@
<H4><A name="4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the <H4><A name="4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the
first few rows of a query? A random row?</H4> first few rows of a query? A random row?</H4>
<P>See the <SMALL>FETCH</SMALL> manual page, or use <P>To retrieve only a few rows, if you know at the number of rows
<SMALL>SELECT</SMALL> ... <SMALL>LIMIT</SMALL>....</P> needed at the time of the <SMALL>SELECT</SMALL> use
<SMALL>LIMIT</SMALL> . If an index matches the <SMALL>ORDER
<P>The entire query may have to be evaluated, even if you only want BY</SMALL> it is possible the entire query does not have to be
the first few rows. Consider using a query that has an <SMALL>ORDER executed. If you don't know the number of rows at
BY</SMALL>. If there is an index that matches the <SMALL>ORDER <SMALL>SELECT</SMALL> time, use a cursor and
BY</SMALL>, PostgreSQL may be able to evaluate only the first few <SMALL>FETCH</SMALL>.</P>
records requested, or the entire query may have to be evaluated
until the desired rows have been generated.</P>
<P>To <SMALL>SELECT</SMALL> a random row, use: <P>To <SMALL>SELECT</SMALL> a random row, use:
<PRE> <PRE>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment