]> granicus.if.org Git - postgresql/commitdiff
Add MIN/MAX LIMIT/OFFSET mention.
authorBruce Momjian <bruce@momjian.us>
Sun, 23 Jun 2002 21:16:29 +0000 (21:16 +0000)
committerBruce Momjian <bruce@momjian.us>
Sun, 23 Jun 2002 21:16:29 +0000 (21:16 +0000)
doc/FAQ
doc/src/FAQ/FAQ.html

diff --git a/doc/FAQ b/doc/FAQ
index a60063eac184baed71c93e0a8ca82d5ebf413b6b..a1f9d150ba7a94ce3c77cc6c9cc685aaad18ad13 100644 (file)
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,7 +1,7 @@
 
                 Frequently Asked Questions (FAQ) for PostgreSQL
                                        
-   Last updated: Thu Jun 20 22:00:57 EDT 2002
+   Last updated: Sun Jun 23 17:16:13 EDT 2002
    
    Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
    
    Indexes are not automatically used by every query. Indexes are only
    used if the table is larger than a minimum size, and the query selects
    only a small percentage of the rows in the table. This is because the
-   random disk access caused by an index scan is sometimes slower than a
+   random disk access caused by an index scan can be slower than a
    straight read through the table, or sequential scan.
    
    To determine if an index should be used, PostgreSQL must have
    sequential scan followed by an explicit sort is usually faster than an
    index scan of a large table.
    However, LIMIT combined with ORDER BY often will use an index because
-   only a small portion of the table is returned.
-   
+   only a small portion of the table is returned. In fact, though MAX()
+   and MIN() don't use indexes, it is possible to retrieve such values
+   using an index with ORDER BY and LIMIT:
+    SELECT col
+    FROM tab
+    ORDER BY col
+    LIMIT 1
+
    When using wild-card operators such as LIKE or ~, indexes can only be
    used if the beginning of the search is anchored to the start of the
    string. Therefore, to use indexes, LIKE patterns must not start with
index 08e9c9d98ebb36ede10a6dd588383880aa2fa481..b6de1a6d49992973ac04c2ac8907224d73c1fa6b 100644 (file)
@@ -14,7 +14,7 @@
   alink="#0000ff">
     <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
 
-    <P>Last updated: Thu Jun 20 22:00:57 EDT 2002</P>
+    <P>Last updated: Sun Jun 23 17:16:13 EDT 2002</P>
 
     <P>Current maintainer: Bruce Momjian (<A href=
     "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
     Indexes are not automatically used by every query. Indexes are only
     used if the table is larger than a minimum size, and the query
     selects only a small percentage of the rows in the table. This is
-    because the random disk access caused by an index scan is sometimes
+    because the random disk access caused by an index scan can be
     slower than a straight read through the table, or sequential scan. 
 
     <P>To determine if an index should be used, PostgreSQL must have
     usually faster than an index scan of a large table.</P>
     However, <SMALL>LIMIT</SMALL> combined with <SMALL>ORDER BY</SMALL>
     often will use an index because only a small portion of the table
-    is returned. 
+    is returned.  In fact, though MAX() and MIN() don't use indexes,
+    it is possible to retrieve such values using an index with ORDER BY
+    and LIMIT:
+<PRE>
+    SELECT col
+    FROM tab
+    ORDER BY col
+    LIMIT 1
+</PRE>
 
     <P>When using wild-card operators such as <SMALL>LIKE</SMALL> or
     <I>~</I>, indexes can only be used if the beginning of the search