Update FAQ.
authorBruce Momjian
Fri, 4 Jan 2002 05:44:45 +0000 (05:44 +0000)
committerBruce Momjian
Fri, 4 Jan 2002 05:44:45 +0000 (05:44 +0000)
doc/FAQ
doc/src/FAQ/FAQ.html

diff --git a/doc/FAQ b/doc/FAQ
index a4416469962cb1392bd3fd95f2c6f87431dbb8b3..7d821c59c4a622827312531bcd5a76e09a82ce81 100644 (file)
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,7 +1,7 @@
 
                 Frequently Asked Questions (FAQ) for PostgreSQL
                                        
-   Last updated: Wed Dec 5 00:41:12 EST 2001
+   Last updated: Fri Jan 4 00:44:42 EST 2002
    
    Current maintainer: Bruce Momjian ([email protected])
    
    
                            Operational Questions
                                       
-   4.1) Why is the system confused about commas, decimal points, and date
-   formats.
-   4.2) What is the exact difference between binary cursors and normal
-   cursors?
-   4.3) How do I SELECT only the first few rows of a query?
-   4.4) How do I get a list of tables or other things I can see in psql?
-   4.5) How do you remove a column from a table?
-   4.6) What is the maximum size for a row, table, database?
-   4.7) How much database disk space is required to store data from a
+   4.1) What is the difference between binary cursors and normal cursors?
+   4.2) How do I SELECT only the first few rows of a query?
+   4.3) How do I get a list of tables or other things I can see in psql?
+   4.4) How do you remove a column from a table?
+   4.5) What is the maximum size for a row, table, database?
+   4.6) How much database disk space is required to store data from a
    typical text file?
-   4.8) How do I find out what tables or indexes are defined in the
+   4.7) How do I find out what tables or indexes are defined in the
    database?
-   4.9) My queries are slow or don't make use of the indexes. Why?
-   4.10) How do I see how the query optimizer is evaluating my query?
-   4.11) What is an R-tree index?
-   4.12) What is the Genetic Query Optimizer?
-   4.13) How do I perform regular expression searches and
+   4.8) My queries are slow or don't make use of the indexes. Why?
+   4.9) How do I see how the query optimizer is evaluating my query?
+   4.10) What is an R-tree index?
+   4.11) What is the Genetic Query Optimizer?
+   4.12) How do I perform regular expression searches and
    case-insensitive regular expression searches? How do I use an index
    for case-insensitive searches?
-   4.14) In a query, how do I detect if a field is NULL?
-   4.15) What is the difference between the various character types?
-   4.16.1) How do I create a serial/auto-incrementing field?
-   4.16.2) How do I get the value of a SERIAL insert?
-   4.16.3) Don't currval() and nextval() lead to a race condition with
+   4.13) In a query, how do I detect if a field is NULL?
+   4.14) What is the difference between the various character types?
+   4.15.1) How do I create a serial/auto-incrementing field?
+   4.15.2) How do I get the value of a SERIAL insert?
+   4.15.3) Don't currval() and nextval() lead to a race condition with
    other users?
-   4.17) What is an OID? What is a TID?
-   4.18) What is the meaning of some of the terms used in PostgreSQL?
-   4.19) Why do I get the error "ERROR: Memory exhausted in
+   4.16) What is an OID? What is a TID?
+   4.17) What is the meaning of some of the terms used in PostgreSQL?
+   4.18) Why do I get the error "ERROR: Memory exhausted in
    AllocSetAlloc()?"
-   4.20) How do I tell what PostgreSQL version I am running?
-   4.21) My large-object operations get invalid large obj descriptor.
+   4.19) How do I tell what PostgreSQL version I am running?
+   4.20) My large-object operations get invalid large obj descriptor.
    Why?
-   4.22) How do I create a column that will default to the current time?
-   4.23) Why are my subqueries using IN so slow?
-   4.24) How do I perform an outer join?
-   4.25) How do I perform queries using multiple databases?
+   4.21) How do I create a column that will default to the current time?
+   4.22) Why are my subqueries using IN so slow?
+   4.23) How do I perform an outer join?
+   4.24) How do I perform queries using multiple databases?
    
                             Extending PostgreSQL
                                       
    
                            Operational Questions
                                       
-    4.1) Why is system confused about commas, decimal points, and date formats.
-    
-   Check your locale configuration. PostgreSQL uses the locale setting of
-   the user that ran the postmaster process. There are postgres and psql
-   SET commands to control the date format. Set those accordingly for
-   your operating environment.
-   
-    4.2) What is the exact difference between binary cursors and normal
-    cursors?
+    4.1) What is the difference between binary cursors and normal cursors?
     
    See the DECLARE manual page for a description.
    
-    4.3) How do I SELECT only the first few rows of a query?
+    4.2) How do I SELECT only the first few rows of a query?
     
    See the FETCH manual page, or use SELECT ... LIMIT....
    
    only the first few records requested, or the entire query may have to
    be evaluated until the desired rows have been generated.
    
-    4.4) How do I get a list of tables or other things I can see in psql?
+    4.3) How do I get a list of tables or other things I can see in psql?
     
    You can read the source code for psql in file
    pgsql/src/bin/psql/describe.c. It contains SQL commands that generate
    the -E option so it will print out the queries it uses to execute the
    commands you give.
    
-    4.5) How do you remove a column from a table?
+    4.4) How do you remove a column from a table?
     
    We do not support ALTER TABLE DROP COLUMN, but do this:
     SELECT ...  -- select all columns but the one you want to remove
     DROP TABLE old_table;
     ALTER TABLE new_table RENAME TO old_table;
 
-    4.6) What is the maximum size for a row, table, database?
+    4.5) What is the maximum size for a row, table, database?
     
    These are the limits:
     Maximum size for a database?             unlimited (60GB databases exist)
    The maximum table size and maximum number of columns can be increased
    if the default block size is increased to 32k.
    
-    4.7) How much database disk space is required to store data from a typical
+    4.6) How much database disk space is required to store data from a typical
     text file?
     
    A PostgreSQL database may need six-and-a-half times the disk space
    Indexes do not require as much overhead, but do contain the data that
    is being indexed, so they can be large also.
    
-    4.8) How do I find out what tables or indexes are defined in the database?
+    4.7) How do I find out what tables or indexes are defined in the database?
     
    psql has a variety of backslash commands to show such information. Use
    \? to see them.
    many of the SELECTs needed to get information from the database system
    tables.
    
-    4.9) My queries are slow or don't make use of the indexes. Why?
+    4.8) My queries are slow or don't make use of the indexes. Why?
     
    PostgreSQL does not automatically maintain statistics. VACUUM must be
    run to update the statistics. After statistics are updated, the
    string. So, to use indices, LIKE searches should not begin with %, and
    ~(regular expression searches) should start with ^.
    
-    4.10) How do I see how the query optimizer is evaluating my query?
+    4.9) How do I see how the query optimizer is evaluating my query?
     
    See the EXPLAIN manual page.
    
-    4.11) What is an R-tree index?
+    4.10) What is an R-tree index?
     
    An R-tree index is used for indexing spatial data. A hash index can't
    handle range searches. A B-tree index only handles range searches in a
    extending R-trees requires a bit of work and we don't currently have
    any documentation on how to do it.
    
-    4.12) What is the Genetic Query Optimizer?
+    4.11) What is the Genetic Query Optimizer?
     
    The GEQO module speeds query optimization when joining many tables by
    means of a Genetic Algorithm (GA). It allows the handling of large
    join queries through nonexhaustive search.
    
-    4.13) How do I perform regular expression searches and case-insensitive
+    4.12) How do I perform regular expression searches and case-insensitive
     regular expression searches? How do I use an index for case-insensitive
     searches?
     
     CREATE INDEX tabindex on tab (lower(col));
 
 
-    4.14) In a query, how do I detect if a field is NULL?
+    4.13) In a query, how do I detect if a field is NULL?
     
    You test the column with IS NULLIS NOT NULL.
    
-    4.15) What is the difference between the various character types?
+    4.14) What is the difference between the various character types?
     
 Type            Internal Name   Notes
 --------------------------------------------------
@@ -817,7 +806,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
    maximum 1 gigabyte. BYTEA is for storing binary data, particularly
    values that include NULL bytes.
    
-    4.16.1) How do I create a serial/auto-incrementing field?
+    4.15.1) How do I create a serial/auto-incrementing field?
     
    PostgreSQL supports a SERIAL data type. It auto-creates a sequence and
    index on the column. For example, this:
@@ -841,11 +830,11 @@ BYTEA           bytea           variable-length byte array (null-safe)
    
    Numbering Rows.
    
-    4.16.2) How do I get the value of a SERIAL insert?
+    4.15.2) How do I get the value of a SERIAL insert?
     
    One approach is to to retrieve the next SERIAL value from the sequence
    object with the nextval() function before inserting and then insert it
-   explicitly. Using the example table in 4.16.1, that might look like
+   explicitly. Using the example table in 4.15.1, that might look like
    this in Perl:
     new_id = output of "SELECT nextval('person_id_seq')"
     INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal');
@@ -867,13 +856,13 @@ BYTEA           bytea           variable-length byte array (null-safe)
    oid value is made available via $sth->{pg_oid_status} after
    $sth->execute().
    
-    4.16.3) Don't currval() and nextval() lead to a race condition with other
+    4.15.3) Don't currval() and nextval() lead to a race condition with other
     users?
     
    No. Currval() returns the current value assigned by your backend, not
    by all users.
    
-    4.17) What is an OID? What is a TID?
+    4.16) What is an OID? What is a TID?
     
    OIDs are PostgreSQL's answer to unique row ids. Every row that is
    created in PostgreSQL gets a unique OID. All OIDs generated during
@@ -906,7 +895,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
    values. Tids change after rows are modified or reloaded. They are used
    by index entries to point to physical rows.
    
-    4.18) What is the meaning of some of the terms used in PostgreSQL?
+    4.17) What is the meaning of some of the terms used in PostgreSQL?
     
    Some of the source code and older documentation use terms that have
    more common usage. Here are some:
@@ -923,7 +912,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
    A list of general database terms can be found at:
    http://www.comptechnews.com/~reaster/dbdesign.html
    
-    4.19) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()?"
+    4.18) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()?"
     
    If you are running a version older than 7.1, an upgrade may fix the
    problem. Also it is possible you have run out of virtual memory on
@@ -939,11 +928,11 @@ BYTEA           bytea           variable-length byte array (null-safe)
    problem with the SQL client because the backend is returning too much
    data, try it before starting the client.
    
-    4.20) How do I tell what PostgreSQL version I am running?
+    4.19) How do I tell what PostgreSQL version I am running?
     
    From psql, type select version();
    
-    4.21) My large-object operations get invalid large obj descriptor. Why?
+    4.20) My large-object operations get invalid large obj descriptor. Why?
     
    You need to put BEGIN WORK and COMMIT around any use of a large object
    handle, that is, surrounding lo_open ... lo_close.
@@ -957,12 +946,12 @@ BYTEA           bytea           variable-length byte array (null-safe)
    If you are using a client interface like ODBC you may need to set
    auto-commit off.
    
-    4.22) How do I create a column that will default to the current time?
+    4.21) How do I create a column that will default to the current time?
     
    Use CURRENT_TIMESTAMP:
 CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
 
-    4.23) 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 sequentially
    scanning the result of the subquery for each row of the outer query. A
@@ -978,7 +967,7 @@ SELECT *
 
    We hope to fix this limitation in a future release.
    
-    4.24) How do I perform an outer join?
+    4.23) How do I perform an outer join?
     
    PostgreSQL 7.1 and later supports outer joins using the SQL standard
    syntax. Here are two examples:
@@ -1008,7 +997,7 @@ SELECT *
     WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
     ORDER BY col1
 
-    4.25) How do I perform queries using multiple databases?
+    4.24) How do I perform queries using multiple databases?
     
    There is no way to query any database except the current one. Because
    PostgreSQL loads database-specific system catalogs, it is uncertain
index dd5eb71073ad89a0fc61b9eee9133e9bc7ccd06e..1133ab77d2f6bad6305d6ac01751ab7e41a8f626 100644 (file)
@@ -11,7 +11,7 @@
   alink="#0000FF">
     

Frequently Asked Questions (FAQ) for PostgreSQL

 
-    

Last updated: Wed Dec  5 00:41:12 EST 2001

+    

Last updated: Fri Jan  4 00:44:42 EST 2002

 
     

Current maintainer: Bruce Momjian (

     
       

Operational Questions

     
-    4.1) Why is the system confused about commas,
-    decimal points, and date formats.
-     4.2) What is the exact difference between
+     4.1) What is the difference between
     binary cursors and normal cursors?
-     3">4.3) How do I SELECT only the
+     2">4.2) How do I SELECT only the
     first few rows of a query?
-     4">4.4) How do I get a list of tables or other
+     3">4.3) How do I get a list of tables or other
     things I can see in psql?
-     5">4.5) How do you remove a column from a
+     4">4.4) How do you remove a column from a
     table?
-     6">4.6) What is the maximum size for a row, table,
+     5">4.5) What is the maximum size for a row, table,
     database?
-     7">4.7) How much database disk space is required
+     6">4.6) How much database disk space is required
     to store data from a typical text file?
-     8">4.8) How do I find out what tables or indexes
+     7">4.7) How do I find out what tables or indexes
     are defined in the database?
-     9">4.9) My queries are slow or don't make use of
+     8">4.8) My queries are slow or don't make use of
     the indexes. Why?
-     10">4.10) How do I see how the query optimizer is
+     9">4.9) How do I see how the query optimizer is
     evaluating my query?
-     1">4.11) What is an R-tree index?
-     2">4.12) What is the Genetic Query Optimizer?
-     3">4.13) How do I perform regular expression
+     0">4.10) What is an R-tree index?
+     1">4.11) What is the Genetic Query Optimizer?
+     2">4.12) How do I perform regular expression
     searches and case-insensitive regular expression searches? How do I
     use an index for case-insensitive searches?
-     4">4.14) In a query, how do I detect if a field
+     3">4.13) In a query, how do I detect if a field
     is NULL?
-     5">4.15) What is the difference between the
+     4">4.14) What is the difference between the
     various character types?
-     6.1">4.16.1) How do I create a
+     5.1">4.15.1) How do I create a
     serial/auto-incrementing field?
-     6.2">4.16.2) How do I get the value of a
+     5.2">4.15.2) How do I get the value of a
     SERIAL insert?
-     6.3">4.16.3) Don't currval() and
+     5.3">4.15.3) Don't currval() and
     nextval() lead to a race condition with other users?
-     7">4.17) What is an OID? What is a
+     6">4.16) What is an OID? What is a
     TID?
-     8">4.18) What is the meaning of some of the terms
+     7">4.17) What is the meaning of some of the terms
     used in PostgreSQL?
-     9">4.19) Why do I get the error "ERROR: 
+     8">4.18) Why do I get the error "ERROR: 
      Memory exhausted in AllocSetAlloc()?"
-     20">4.20) How do I tell what PostgreSQL version I
+     19">4.19) How do I tell what PostgreSQL version I
     am running? 
-     1">4.21) My large-object operations get
+     0">4.20) My large-object operations get
     invalid large obj descriptor. Why?
-     2">4.22) How do I create a column that will
+     1">4.21) How do I create a column that will
     default to the current time?
-     3">4.23) Why are my subqueries using
+     2">4.22) Why are my subqueries using
     IN so slow?
-     4">4.24) How do I perform an outer join?
-     5">4.25) How do I perform queries using multiple databases?
+     3">4.23) How do I perform an outer join?
+     4">4.24) How do I perform queries using multiple databases?
      
 
     
       

Operational Questions

     
 
-    

4.1) Why is system confused about commas,

-    decimal points, and date formats.
-
-    

Check your locale configuration. PostgreSQL uses the locale

-    setting of the user that ran the postmaster process. There
-    are postgres and psql SET commands to control the
-    date format. Set those accordingly for your operating
-    environment.

-
-    

4.2) What is the exact difference between

+    

4.1) What is the difference between

     binary cursors and normal cursors?
 
     

See the DECLARE manual page for a

     description.

 
-    

3">4.3) How do I SELECT only the

+    

2">4.2) How do I SELECT only the

     first few rows of a query?
 
     

See the FETCH manual page, or use

     records requested, or the entire query may have to be evaluated
     until the desired rows have been generated.

 
-    

4">4.4) How do I get a list of tables or other

+    

3">4.3) How do I get a list of tables or other

     things I can see in psql?
     
 
     -E option so it will print out the queries it uses to
     execute the commands you give.

 
-    

5">4.5) How do you remove a column from a

+    

4">4.4) How do you remove a column from a

     table?
 
     

We do not support ALTER TABLE DROP COLUMN, but do

     ALTER TABLE new_table RENAME TO old_table;
 
 
-    

6">4.6) What is the maximum size for a row,

+    

5">4.5) What is the maximum size for a row,

     table, database?
 
     

These are the limits:

     

The maximum table size and maximum number of columns can be

     increased if the default block size is increased to 32k.

 
-    

7">4.7) How much database disk space is required

+    

6">4.6) How much database disk space is required

     to store data from a typical text file?
     
 
     

Indexes do not require as much overhead, but do contain the data

     that is being indexed, so they can be large also.

 
-    

8">4.8) How do I find out what tables or indexes

+    

7">4.7) How do I find out what tables or indexes

     are defined in the database?
 
     

psql has a variety of backslash commands to show such

     illustrates many of the SELECTs needed to get
     information from the database system tables.

 
-    

9">4.9) My queries are slow or don't make use of

+    

8">4.8) My queries are slow or don't make use of

     the indexes. Why?
 
     

PostgreSQL does not automatically maintain statistics.

     ~(regular expression searches) should start with
     ^.

 
-    

10">4.10) How do I see how the query optimizer

+    

9">4.9) How do I see how the query optimizer

     is evaluating my query?
 
     

See the EXPLAIN manual page.

 
-    

1">4.11) What is an R-tree index?

+    

0">4.10) What is an R-tree index?

 
     

An R-tree index is used for indexing spatial data. A hash index

     can't handle range searches. A B-tree index only handles range
     practice, extending R-trees requires a bit of work and we don't
     currently have any documentation on how to do it.

 
-    

2">4.12) What is the Genetic Query

+    

1">4.11) What is the Genetic Query

     Optimizer?
 
     

The GEQO module speeds query optimization when

     the handling of large join queries through nonexhaustive
     search.

 
-    

3">4.13) How do I perform regular expression

+    

2">4.12) How do I perform regular expression

     searches and case-insensitive regular expression searches?  How do I
     use an index for case-insensitive searches?
 
     CREATE INDEX tabindex on tab (lower(col));
     
 
-    

4">4.14) In a query, how do I detect if a field

+    

3">4.13) In a query, how do I detect if a field

     is NULL?
 
     

You test the column with IS NULLIS NOT NULL.

 
-    

5">4.15) What is the difference between the

+    

4">4.14) What is the difference between the

     various character types?
 
 Type            Internal Name   Notes
@@ -1034,7 +1023,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
     binary data, particularly values that include NULL
     bytes.

     
-    

6.1">4.16.1) How do I create a

+    

5.1">4.15.1) How do I create a

     serial/auto-incrementing field?
 
     

PostgreSQL supports a SERIAL data type. It

@@ -1064,13 +1053,13 @@ BYTEA           bytea           variable-length byte array (null-safe)
     

Numbering

     Rows.

 
-    

6.2">4.16.2) How do I get the value of a

+    

5.2">4.15.2) How do I get the value of a

     SERIAL insert?
 
     

One approach is to to retrieve the next SERIAL

     value from the sequence object with the nextval() function
     before inserting and then insert it explicitly. Using the
-    example table in 6.1">4.16.1, that might look like
+    example table in 5.1">4.15.1, that might look like
     this in Perl:

 
     new_id = output of "SELECT nextval('person_id_seq')"
@@ -1091,20 +1080,20 @@ BYTEA           bytea           variable-length byte array (null-safe)
     INSERT INTO person (name) VALUES ('Blaise Pascal');
     new_id = output of "SELECT currval('person_id_seq')";
 
-    Finally, you could use the 7">OID
+    Finally, you could use the 6">OID
     returned from the INSERT statement to look up the
     default value, though this is probably the least portable approach.
     In Perl, using DBI with Edmund Mergl's DBD::Pg module, the oid
     value is made available via $sth->{pg_oid_status} after
     $sth->execute(). 
 
-    

6.3">4.16.3) Don't currval() and

+    

5.3">4.15.3) Don't currval() and

     nextval() lead to a race condition with other users?
 
     

No. Currval() returns the current value assigned by your

     backend, not by all users.

 
-    

7">4.17) What is an OID? What is

+    

6">4.16) What is an OID? What is

     a TID?
 
     

OIDs are PostgreSQL's answer to unique row ids.

@@ -1149,7 +1138,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
     or reloaded. They are used by index entries to point to physical
     rows.

 
-    

8">4.18) What is the meaning of some of the

+    

7">4.17) What is the meaning of some of the

     terms used in PostgreSQL?
 
     

Some of the source code and older documentation use terms that

@@ -1178,7 +1167,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
     

A list of general database terms can be found at: 

     "http://www.comptechnews.com/~reaster/dbdesign.html">http://www.comptechnews.com/~reaster/dbdesign.html

 
-    

9">4.19) Why do I get the error "ERROR: 

+    

8">4.18) Why do I get the error "ERROR: 

      Memory exhausted in AllocSetAlloc()?"
     
 
@@ -1198,13 +1187,13 @@ BYTEA           bytea           variable-length byte array (null-safe)
     backend is returning too much data, try it before starting the
     client. 
 
-    

20">4.20) How do I tell what PostgreSQL version

+    

19">4.19) How do I tell what PostgreSQL version

     I am running?
     
 
     

From psql, type select version();

 
-    

1">4.21) My large-object operations get

+    

0">4.20) My large-object operations get

     invalid large obj descriptor. Why?
     
 
@@ -1221,7 +1210,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
     

If you are using a client interface like ODBC you

     may need to set auto-commit off.

 
-    

2">4.22) How do I create a column that will

+    

1">4.21) How do I create a column that will

     default to the current time?
     
 
@@ -1231,7 +1220,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
 
 
 
-    

3">4.23) Why are my subqueries using

+    

2">4.22) Why are my subqueries using

     IN so slow?
     
 
@@ -1254,7 +1243,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
 
     We hope to fix this limitation in a future release. 
 
-    

4">4.24) How do I perform an outer join?

+    

3">4.23) How do I perform an outer join?

     
 
     

PostgreSQL 7.1 and later supports outer joins using the SQL

@@ -1295,7 +1284,7 @@ BYTEA           bytea           variable-length byte array (null-safe)
     ORDER BY col1
 
 
-    

5">4.25) How do I perform queries

+    

4">4.24) How do I perform queries

     using multiple databases?
 
     

There is no way to query any database except the current one.