Update FAQ.

This commit is contained in:
Bruce Momjian 2000-07-26 02:20:02 +00:00
parent 0e06e68387
commit 4108bf6def
2 changed files with 189 additions and 208 deletions

204
doc/FAQ
View File

@ -5,8 +5,8 @@
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
The most recent version of this document can be viewed at the The most recent version of this document can be viewed at
PostgreSQL Web site, http://www.PostgreSQL.org. http://www.PostgreSQL.org/docs/faq-english.html.
Linux-specific questions are answered in Linux-specific questions are answered in
http://www.PostgreSQL.org/docs/faq-linux.html. http://www.PostgreSQL.org/docs/faq-linux.html.
@ -28,9 +28,9 @@
1.3) What Unix platforms does PostgreSQL run on? 1.3) What Unix platforms does PostgreSQL run on?
1.4) What non-unix ports are available? 1.4) What non-unix ports are available?
1.5) Where can I get PostgreSQL? 1.5) Where can I get PostgreSQL?
1.6) Where can I get support for PostgreSQL? 1.6) Where can I get support?
1.7) What is the latest release of PostgreSQL? 1.7) What is the latest release?
1.8) What documentation is available for PostgreSQL? 1.8) What documentation is available?
1.9) How do I find out about known bugs or missing features? 1.9) How do I find out about known bugs or missing features?
1.10) How can I learn SQL? 1.10) How can I learn SQL?
1.11) Is PostgreSQL Y2K compliant? 1.11) Is PostgreSQL Y2K compliant?
@ -53,8 +53,8 @@
/usr/local/pgsql? /usr/local/pgsql?
3.3) When I start the postmaster, I get a Bad System Call or core 3.3) When I start the postmaster, I get a Bad System Call or core
dumped message. Why? dumped message. Why?
3.4) When I try to start the postmaster, I get IpcMemoryCreate 3.4) When I try to start the postmaster, I get IpcMemoryCreate errors.
errors3. Why? Why?
3.5) When I try to start the postmaster, I get IpcSemaphoreCreate 3.5) When I try to start the postmaster, I get IpcSemaphoreCreate
errors. Why? errors. Why?
3.6) How do I prevent other hosts from accessing my PostgreSQL 3.6) How do I prevent other hosts from accessing my PostgreSQL
@ -63,22 +63,22 @@
3.8) Why can't I access the database as the root user? 3.8) Why can't I access the database as the root user?
3.9) All my servers crash under concurrent table access. Why? 3.9) All my servers crash under concurrent table access. Why?
3.10) How do I tune the database engine for better performance? 3.10) How do I tune the database engine for better performance?
3.11) What debugging features are available in PostgreSQL? 3.11) What debugging features are available?
3.12) I get 'Sorry, too many clients' when trying to connect. Why? 3.12) I get "Sorry, too many clients" when trying to connect. Why?
3.13) What are the pg_psort.XXX files in my database directory? 3.13) What are the pg_sorttempNNN.NN files in my database directory?
Operational Questions Operational Questions
4.1) The system seems to be confused about commas, decimal points, and 4.1) Why is the system confused about commas, decimal points, and date
date formats. formats.
4.2) What is the exact difference between binary cursors and normal 4.2) What is the exact difference between binary cursors and normal
cursors? cursors?
4.3) How do I select only the first few rows of a query? 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.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.5) How do you remove a column from a table?
4.6) What is the maximum size for a row, table, database? 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.7) How much database disk space is required to store data from a
typical flat file? typical text file?
4.8) How do I find out what indices or operations are defined in the 4.8) How do I find out what indices or operations are defined in the
database? database?
4.9) My queries are slow or don't make use of the indexes. Why? 4.9) My queries are slow or don't make use of the indexes. Why?
@ -86,7 +86,7 @@
4.11) What is an R-tree index? 4.11) What is an R-tree index?
4.12) What is Genetic Query Optimization? 4.12) What is Genetic Query Optimization?
4.13) How do I do regular expression searches and case-insensitive 4.13) How do I do regular expression searches and case-insensitive
regexp searching? regular expression searching?
4.14) In a query, how do I detect if a field is NULL? 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.15) What is the difference between the various character types?
4.16.1) How do I create a serial/auto-incrementing field? 4.16.1) How do I create a serial/auto-incrementing field?
@ -110,7 +110,7 @@
it dump core? it dump core?
5.2) What does the message: NOTICE:PortalHeapMemoryFree: 0x402251d0 5.2) What does the message: NOTICE:PortalHeapMemoryFree: 0x402251d0
not in alloc set! mean? not in alloc set! mean?
5.3) How can I contribute some nifty new types and functions for 5.3) How can I contribute some nifty new types and functions to
PostgreSQL? PostgreSQL?
5.4) How do I write a C function to return a tuple? 5.4) How do I write a C function to return a tuple?
5.5) I have changed a source file. Why does the recompile does not see 5.5) I have changed a source file. Why does the recompile does not see
@ -131,7 +131,7 @@
developers who all subscribe to the PostgreSQL development mailing developers who all subscribe to the PostgreSQL development mailing
list. The current coordinator is Marc G. Fournier list. The current coordinator is Marc G. Fournier
(scrappy@PostgreSQL.org). (See below on how to join). This team is now (scrappy@PostgreSQL.org). (See below on how to join). This team is now
responsible for all current and future development of PostgreSQL. responsible for all development of PostgreSQL.
The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. Many The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. Many
others have contributed to the porting, testing, debugging and others have contributed to the porting, testing, debugging and
@ -205,14 +205,14 @@
libpq library and psql. libpq library and psql.
The database server is now working on Windows NT using the Cygnus The database server is now working on Windows NT using the Cygnus
Unix/NT porting library. See pgsql/doc/README.NT in the distribution. Unix/NT porting library. See pgsql/doc/FAQ_NT in the distribution.
1.5) Where can I get PostgreSQL? 1.5) Where can I get PostgreSQL?
The primary anonymous ftp site for PostgreSQL is The primary anonymous ftp site for PostgreSQL is
ftp://ftp.PostgreSQL.org/pub. For mirror sites, see our main web site. ftp://ftp.PostgreSQL.org/pub. For mirror sites, see our main web site.
1.6) Where can I get support for PostgreSQL? 1.6) Where can I get support?
There is no official support for PostgreSQL from the University of There is no official support for PostgreSQL from the University of
California, Berkeley. It is maintained through volunteer effort. California, Berkeley. It is maintained through volunteer effort.
@ -258,26 +258,25 @@
Commercial support for PostgreSQL is available at Commercial support for PostgreSQL is available at
http://www.pgsql.com/. http://www.pgsql.com/.
1.7) What is the latest release of PostgreSQL? 1.7) What is the latest release?
The latest release of PostgreSQL is version 7.0.2. The latest release of PostgreSQL is version 7.0.2.
We plan to have major releases every four months. We plan to have major releases every four months.
1.8) What documentation is available for PostgreSQL? 1.8) What documentation is available?
Several manuals, manual pages, and some small test examples are Several manuals, manual pages, and some small test examples are
included in the distribution. See the /doc directory. You can also included in the distribution. See the /doc directory. You can also
browse the manual on-line at http://www.PostgreSQL.org/docs/postgres. browse the manual on-line at http://www.PostgreSQL.org/docs/postgres.
in the distribution.
There is a PostgreSQL book availiable at There is a PostgreSQL book available at
http://www.PostgreSQL.org/docs/awbook.html http://www.PostgreSQL.org/docs/awbook.html.
psql has some nice \d commands to show information about types, psql has some nice \d commands to show information about types,
operators, functions, aggregates, etc. operators, functions, aggregates, etc.
The web site contains even more documentation. Our web site contains even more documentation.
1.9) How do I find out about known bugs or missing features? 1.9) How do I find out about known bugs or missing features?
@ -310,10 +309,10 @@
submit high-quality patches to pgsql-patches. submit high-quality patches to pgsql-patches.
There are about a dozen people who have commit privileges to the There are about a dozen people who have commit privileges to the
PostgreSQL CVS archive. All of them have submitted so many PostgreSQL CVS archive. They each have submitted so many high-quality
high-quality patches that it was a pain for the existing committers to patches that it was a pain for the existing committers to keep up, and
keep up, and we had confidence that patches they committed were likely we had confidence that patches they committed were likely to be of
to be of high quality. high quality.
1.13) How do I submit a bug report? 1.13) How do I submit a bug report?
@ -347,8 +346,7 @@
though in this mode, an OS crash could cause data corruption. though in this mode, an OS crash could cause data corruption.
We are working to provide an intermediate mode that suffers We are working to provide an intermediate mode that suffers
less performance overhead than full fsync mode, and will allow less performance overhead than full fsync mode, and will allow
data integrity within 30 seconds of an OS crash. The mode is data integrity within 30 seconds of an OS crash.
select-able by the database administrator.
In comparison to MySQL or leaner database systems, we are In comparison to MySQL or leaner database systems, we are
slower on inserts/updates because we have transaction overhead. slower on inserts/updates because we have transaction overhead.
Of course, MySQL doesn't have any of the features mentioned in Of course, MySQL doesn't have any of the features mentioned in
@ -393,7 +391,7 @@
There are two ODBC drivers available, PsqlODBC and OpenLink ODBC. There are two ODBC drivers available, PsqlODBC and OpenLink ODBC.
PsqlODBC is included in the distribution. More information about it PsqlODBC is included in the distribution. More information about it
can be gotten from: ftp://ftp.PostgreSQL.org/pub/odbc/index.html can be gotten from ftp://ftp.PostgreSQL.org/pub/odbc/.
OpenLink ODBC can be gotten from http://www.openlinksw.com. It works OpenLink ODBC can be gotten from http://www.openlinksw.com. It works
with their standard ODBC client software so you'll have PostgreSQL with their standard ODBC client software so you'll have PostgreSQL
@ -413,7 +411,7 @@
There is also one at http://www.phone.net/home/mwm/hotlist/. There is also one at http://www.phone.net/home/mwm/hotlist/.
For web integration, PHP is an excellent interface. It is at: For web integration, PHP is an excellent interface. It is at
http://www.php.net http://www.php.net
PHP is great for simple stuff, but for more complex cases, many use PHP is great for simple stuff, but for more complex cases, many use
@ -473,12 +471,12 @@
3.4) When I try to start the postmaster, I get IpcMemoryCreate errors. Why? 3.4) When I try to start the postmaster, I get IpcMemoryCreate errors. Why?
You either do not have shared memory configured properly in kernel or You either do not have shared memory configured properly in your
you need to enlarge the shared memory available in the kernel. The kernel or you need to enlarge the shared memory available in the
exact amount you need depends on your architecture and how many kernel. The exact amount you need depends on your architecture and how
buffers and backend processes you configure postmaster to run with. many buffers and backend processes you configure postmaster to run
For most systems, with default numbers of buffers and processes, you with. For most systems, with default numbers of buffers and processes,
need a minimum of ~1MB. you need a minimum of ~1MB.
3.5) When I try to start the postmaster, I get IpcSemaphoreCreate errors. 3.5) When I try to start the postmaster, I get IpcSemaphoreCreate errors.
Why? Why?
@ -507,8 +505,7 @@
The default configuration allows only unix domain socket connections The default configuration allows only unix domain socket connections
from the local machine. To enable TCP/IP connections, make sure the from the local machine. To enable TCP/IP connections, make sure the
postmaster has been started with the -i option, and add an appropriate postmaster has been started with the -i option, and add an appropriate
host entry to the file pgsql/data/pg_hba.conf. See the pg_hba.conf host entry to the file pgsql/data/pg_hba.conf.
manual page.
3.8) Why can't I access the database as the root user? 3.8) Why can't I access the database as the root user?
@ -529,11 +526,11 @@
indices are being used. indices are being used.
If you are doing a lot of INSERTs, consider doing them in a large If you are doing a lot of INSERTs, consider doing them in a large
batch using the COPY command. This is much faster than single batch using the COPY command. This is much faster than individual
individual INSERTS. Second, statements not in a BEGIN WORK/COMMIT INSERTS. Second, statements not in a BEGIN WORK/COMMIT transaction
transaction block are considered to be in their own transaction. block are considered to be in their own transaction. Consider
Consider performing several statements in a single transaction block. performing several statements in a single transaction block. This
This reduces the transaction overhead. Also consider dropping and reduces the transaction overhead. Also consider dropping and
recreating indices when making large data changes. recreating indices when making large data changes.
There are several tuning things that can be done. You can disable There are several tuning things that can be done. You can disable
@ -542,7 +539,7 @@
You can also use the postmaster -B option to increase the number of You can also use the postmaster -B option to increase the number of
shared memory buffers used by the backend processes. If you make this shared memory buffers used by the backend processes. If you make this
parameter too high, the postmaster may not start up because you've parameter too high, the postmaster may not start because you've
exceeded your kernel's limit on shared memory space. Each buffer is 8K exceeded your kernel's limit on shared memory space. Each buffer is 8K
and the default is 64 buffers. and the default is 64 buffers.
@ -550,10 +547,10 @@
of memory used by the backend process for temporary sorts. The -S of memory used by the backend process for temporary sorts. The -S
value is measured in kilobytes, and the default is 512 (ie, 512K). value is measured in kilobytes, and the default is 512 (ie, 512K).
You can also use the CLUSTER command to group data in base tables to You can also use the CLUSTER command to group data in tables to match
match an index. See the cluster(l) manual page for more details. an index. See the cluster(l) manual page for more details.
3.11) What debugging features are available in PostgreSQL? 3.11) What debugging features are available?
PostgreSQL has several features that report status information that PostgreSQL has several features that report status information that
can be valuable for debugging purposes. can be valuable for debugging purposes.
@ -607,7 +604,7 @@
In PostgreSQL 6.5 and up, the default limit is 32 processes. You can In PostgreSQL 6.5 and up, the default limit is 32 processes. You can
increase it by restarting the postmaster with a suitable -N value. increase it by restarting the postmaster with a suitable -N value.
With the default configuration you can set -N as large as 1024; if you With the default configuration you can set -N as large as 1024. If you
need more, increase MAXBACKENDS in include/config.h and rebuild. You need more, increase MAXBACKENDS in include/config.h and rebuild. You
can set the default value of -N at configuration time, if you like, can set the default value of -N at configuration time, if you like,
using configure's --with-maxbackends switch. using configure's --with-maxbackends switch.
@ -622,33 +619,32 @@
processes, NPROC, the maximum number of processes per user, MAXUPRC, processes, NPROC, the maximum number of processes per user, MAXUPRC,
and the maximum number of open files, NFILE and NINODE. The reason and the maximum number of open files, NFILE and NINODE. The reason
that PostgreSQL has a limit on the number of allowed backend processes that PostgreSQL has a limit on the number of allowed backend processes
is so that you can ensure that your system won't run out of resources. is so your system won't run out of resources.
In PostgreSQL versions prior to 6.5, the maximum number of backends In PostgreSQL versions prior to 6.5, the maximum number of backends
was 64, and changing it required a rebuild after altering the was 64, and changing it required a rebuild after altering the
MaxBackendId constant in include/storage/sinvaladt.h. MaxBackendId constant in include/storage/sinvaladt.h.
3.13) What are the pg_tempNNN.NN files in my database directory? 3.13) What are the pg_sorttempNNN.NN files in my database directory?
They are temporary files generated by the query executor. For example, They are temporary files generated by the query executor. For example,
if a sort needs to be done to satisfy an ORDER BY, and the sort if a sort needs to be done to satisfy an ORDER BY, and the sort
requires more space than the backend's -S parameter allows, then temp requires more space than the backend's -S parameter allows, then temp
files are created to hold the extra data. files are created to hold the extra data.
The temp files should go away automatically, but might not if a The temp files should be deleted automatically, but might not if a
backend crashes during a sort. If you have no transactions running at backend crashes during a sort. If you have no backends running at the
the time, it is safe to delete the pg_tempNNN.NN files. time, it is safe to delete the pg_tempNNN.NN files.
_________________________________________________________________ _________________________________________________________________
Operational Questions Operational Questions
4.1) The system seems to be confused about commas, decimal points, and date 4.1) Why is system confused about commas, decimal points, and date formats.
formats.
Check your locale configuration. PostgreSQL uses the locale settings Check your locale configuration. PostgreSQL uses the locale setting of
of the user that ran the postmaster process. There are postgres and the user that ran the postmaster process. There are postgres and psql
psql SET commands to control the date format. Set those accordingly SET commands to control the date format. Set those accordingly for
for your operating environment. your operating environment.
4.2) What is the exact difference between binary cursors and normal 4.2) What is the exact difference between binary cursors and normal
cursors? cursors?
@ -665,12 +661,13 @@
only the first few records requested, or the entire query may have to only the first few records requested, or the entire query may have to
be evaluated until the desired rows have been generated. be evaluated until the desired rows have been generated.
4.4) How do I get a list of tables, or other information I see in psql? 4.4) How do I get a list of tables or other things I can see in psql?
You can read the source code for psql, file pgsql/src/bin/psql/psql.c. You can read the source code for psql in file
It contains SQL commands that generate the output for psql's backslash pgsql/src/bin/psql/psql.c. It contains SQL commands that generate the
commands. You can also start psql with the -E option so that it will output for psql's backslash commands. You can also start psql with the
print out the queries it uses to execute the commands you give. -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.5) How do you remove a column from a table?
@ -701,10 +698,10 @@ Maximum number of indexes on a table? unlimited
Row length limit will be removed in 7.1. Row length limit will be removed in 7.1.
4.7)How much database disk space is required to store data from a typical 4.7)How much database disk space is required to store data from a typical
flat file? text file?
A PostgreSQL database can require about six and a half times the disk A PostgreSQL database may need six and a half times the disk space
space required to store the data in a flat file. required to store the data in a flat file.
Consider a file of 300,000 lines with two integers on each line. The Consider a file of 300,000 lines with two integers on each line. The
flat file is 2.4MB. The size of the PostgreSQL database file flat file is 2.4MB. The size of the PostgreSQL database file
@ -727,7 +724,7 @@ Maximum number of indexes on a table? unlimited
1755 database pages * 8192 bytes per page = 14,376,960 bytes (14MB) 1755 database pages * 8192 bytes per page = 14,376,960 bytes (14MB)
Indexes do not contain as much overhead, but do contain the data that Indexes do not require as much overhead, but do contain the data that
is being indexed, so they can be large also. is being indexed, so they can be large also.
4.8) How do I find out what indices or operations are defined in the 4.8) How do I find out what indices or operations are defined in the
@ -742,12 +739,12 @@ Maximum number of indexes on a table? unlimited
4.9) My queries are slow or don't make use of the indexes. Why? 4.9) My queries are slow or don't make use of the indexes. Why?
PostgreSQL does not automatically maintain statistics. One has to make PostgreSQL does not automatically maintain statistics. VACUUM must be
an explicit VACUUM call to update the statistics. After statistics are run to update the statistics. After statistics are updated, the
updated, the optimizer knows how many rows in the table, and can optimizer knows how many rows in the table, and can better decide if
better decide if it should use indices. Note that the optimizer does it should use indices. Note that the optimizer does not use indices in
not use indices in cases when the table is small because a sequential cases when the table is small because a sequential scan would be
scan would be faster. faster.
For column-specific optimization statistics, use VACUUM ANALYZE. For column-specific optimization statistics, use VACUUM ANALYZE.
VACUUM ANALYZE is important for complex multi-join queries, so the VACUUM ANALYZE is important for complex multi-join queries, so the
@ -794,15 +791,12 @@ Maximum number of indexes on a table? unlimited
4.12) What is Genetic Query Optimization? 4.12) What is Genetic Query Optimization?
The GEQO module in PostgreSQL is intended to solve the query The GEQO module speeds query optimization when joining many tables by
optimization problem of joining many tables by means of a Genetic means of a Genetic Algorithm (GA). It allows the handling of large
Algorithm (GA). It allows the handling of large join queries through join queries through non-exhaustive search.
non-exhaustive search.
For further information see the documentation. 4.13) How do I do regular expression searches and case-insensitive regular
expression searching?
4.13) How do I do regular expression searches and case-insensitive regexp
searching?
The ~ operator does regular-expression matching, and ~* does The ~ operator does regular-expression matching, and ~* does
case-insensitive regular-expression matching. There is no case-insensitive regular-expression matching. There is no
@ -837,7 +831,7 @@ BYTEA bytea variable-length array of bytes
4.16.1) How do I create a serial/auto-incrementing field? 4.16.1) How do I create a serial/auto-incrementing field?
PostgreSQL supports SERIAL data type. It auto-creates a sequence and PostgreSQL supports a SERIAL data type. It auto-creates a sequence and
index on the column. For example, this: index on the column. For example, this:
CREATE TABLE person ( CREATE TABLE person (
id SERIAL, id SERIAL,
@ -861,10 +855,10 @@ BYTEA bytea variable-length array of bytes
4.16.2) How do I get the back the generated SERIAL value after an insert? 4.16.2) How do I get the back the generated SERIAL value after an insert?
Probably the simplest approach is to to retrieve the next SERIAL value One approach is to to retrieve the next SERIAL value from the sequence
from the sequence object with the nextval() function before inserting object with the nextval() function before inserting and then insert it
and then insert it explicitly. Using the example table in 4.16.1, that explicitly. Using the example table in 4.16.1, that might look like
might look like this: this:
$newSerialID = nextval('person_id_seq'); $newSerialID = nextval('person_id_seq');
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal'); INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
@ -874,8 +868,8 @@ BYTEA bytea variable-length array of bytes
named <table>_<serialcolumn>_seq, where table and serialcolumn are the named <table>_<serialcolumn>_seq, where table and serialcolumn are the
names of your table and your SERIAL column, respectively. names of your table and your SERIAL column, respectively.
Similarly, you could retrieve the just-assigned SERIAL value with the Alternatively, you could retrieve the just-assigned SERIAL value with
currval() function after it was inserted by default, e.g., the currval() function after it was inserted by default, e.g.,
INSERT INTO person (name) VALUES ('Blaise Pascal'); INSERT INTO person (name) VALUES ('Blaise Pascal');
$newID = currval('person_id_seq'); $newID = currval('person_id_seq');
@ -888,11 +882,11 @@ BYTEA bytea variable-length array of bytes
4.16.3) Don't currval() and nextval() lead to a race condition with other 4.16.3) Don't currval() and nextval() lead to a race condition with other
concurrent backend processes? concurrent backend processes?
No. That has been handled by the backends. No. This is handled by the backends.
4.17) What is an oid? What is a tid? 4.17) What is an oid? What is a tid?
Oids are PostgreSQL's answer to unique row ids. Every row that is OIDs are PostgreSQL's answer to unique row ids. Every row that is
created in PostgreSQL gets a unique oid. All oids generated during created in PostgreSQL gets a unique oid. All oids generated during
initdb are less than 16384 (from backend/access/transam.h). All initdb are less than 16384 (from backend/access/transam.h). All
user-created oids are equal or greater that this. By default, all user-created oids are equal or greater that this. By default, all
@ -902,15 +896,15 @@ BYTEA bytea variable-length array of bytes
PostgreSQL uses oids in its internal system tables to link rows PostgreSQL uses oids in its internal system tables to link rows
between tables. These oids can be used to identify specific user rows between tables. These oids can be used to identify specific user rows
and used in joins. It is recommended you use column type oid to store and used in joins. It is recommended you use column type oid to store
oid values. See the sql(l) manual page to see the other internal oid values. You can create an index on the oid field for faster
columns. You can create an index on the oid field for faster access. access.
Oids are assigned to all new rows from a central area that is used by Oids are assigned to all new rows from a central area that is used by
all databases. If you want to change the oid to something else, or if all databases. If you want to change the oid to something else, or if
you want to make a copy of the table, with the original oid's, there you want to make a copy of the table, with the original oid's, there
is no reason you can't do it: is no reason you can't do it:
CREATE TABLE new_table(old_oid oid, mycol int); CREATE TABLE new_table(old_oid oid, mycol int);
SELECT INTO new SELECT old_oid, mycol FROM old; SELECT old_oid, mycol INTO new FROM old;
COPY new TO '/tmp/pgtable'; COPY new TO '/tmp/pgtable';
DELETE FROM new; DELETE FROM new;
COPY new WITH OIDS FROM '/tmp/pgtable'; COPY new WITH OIDS FROM '/tmp/pgtable';
@ -957,12 +951,11 @@ BYTEA bytea variable-length array of bytes
You need to put BEGIN WORK and COMMIT around any use of a large object You need to put BEGIN WORK and COMMIT around any use of a large object
handle, that is, surrounding lo_open ... lo_close. handle, that is, surrounding lo_open ... lo_close.
Current PostgreSQL enforces the rule by closing large object handles Currently PostgreSQL enforces the rule by closing large object handles
at transaction commit, which will be instantly upon completion of the at transaction commit. So the first attempt to do anything with the
lo_open command if you are not inside a transaction. So the first handle will draw invalid large obj descriptor. So code that used to
attempt to do anything with the handle will draw invalid large obj work (at least most of the time) will now generate that error message
descriptor. So code that used to work (at least most of the time) will if you fail to use a transaction.
now generate that error message if you fail to use a transaction.
If you are using a client interface like ODBC you may need to set If you are using a client interface like ODBC you may need to set
auto-commit off. auto-commit off.
@ -1018,8 +1011,7 @@ BYTEA bytea variable-length array of bytes
You are pfree'ing something that was not palloc'ed. Beware of mixing You are pfree'ing something that was not palloc'ed. Beware of mixing
malloc/free and palloc/pfree. malloc/free and palloc/pfree.
5.3) How can I contribute some nifty new types and functions for 5.3) How can I contribute some nifty new types and functions to PostgreSQL?
PostgreSQL?
Send your extensions to the pgsql-hackers mailing list, and they will Send your extensions to the pgsql-hackers mailing list, and they will
eventually end up in the contrib/ subdirectory. eventually end up in the contrib/ subdirectory.

View File

@ -12,8 +12,9 @@ Last updated: Fri Jun 2 11:32:13 EDT 2000
Current maintainer: Bruce Momjian (<A Current maintainer: Bruce Momjian (<A
HREF="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR><P> HREF="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR><P>
The most recent version of this document can be viewed at the PostgreSQL The most recent version of this document can be viewed at
Web site, <A HREF="http://www.Postgresql.org">http://www.PostgreSQL.org</A>.<P> <A HREF="http://www.Postgresql.org/docs/faq-english.html">
http://www.PostgreSQL.org/docs/faq-english.html</A>.<P>
Linux-specific questions are answered in <A Linux-specific questions are answered in <A
HREF="http://www.PostgreSQL.org/docs/faq-linux.html">http://www.PostgreSQL.org/docs/faq-linux.html</A>.<P> HREF="http://www.PostgreSQL.org/docs/faq-linux.html">http://www.PostgreSQL.org/docs/faq-linux.html</A>.<P>
@ -36,9 +37,9 @@ HREF="http://www.PostgreSQL.org/docs/faq-irix.html">http://www.PostgreSQL.org/do
<A HREF="#1.3">1.3</A>) What Unix platforms does PostgreSQL run on?<BR> <A HREF="#1.3">1.3</A>) What Unix platforms does PostgreSQL run on?<BR>
<A HREF="#1.4">1.4</A>) What non-unix ports are available?<BR> <A HREF="#1.4">1.4</A>) What non-unix ports are available?<BR>
<A HREF="#1.5">1.5</A>) Where can I get PostgreSQL?<BR> <A HREF="#1.5">1.5</A>) Where can I get PostgreSQL?<BR>
<A HREF="#1.6">1.6</A>) Where can I get support for PostgreSQL?<BR> <A HREF="#1.6">1.6</A>) Where can I get support?<BR>
<A HREF="#1.7">1.7</A>) What is the latest release of PostgreSQL?<BR> <A HREF="#1.7">1.7</A>) What is the latest release?<BR>
<A HREF="#1.8">1.8</A>) What documentation is available for PostgreSQL?<BR> <A HREF="#1.8">1.8</A>) What documentation is available?<BR>
<A HREF="#1.9">1.9</A>) How do I find out about known bugs or missing features?<BR> <A HREF="#1.9">1.9</A>) How do I find out about known bugs or missing features?<BR>
<A HREF="#1.10">1.10</A>) How can I learn SQL?<BR> <A HREF="#1.10">1.10</A>) How can I learn SQL?<BR>
<A HREF="#1.11">1.11</A>) Is PostgreSQL Y2K compliant?<BR> <A HREF="#1.11">1.11</A>) Is PostgreSQL Y2K compliant?<BR>
@ -61,13 +62,13 @@ with PostgreSQL?<BR>
<H2><CENTER>Administrative Questions</CENTER></H2> <H2><CENTER>Administrative Questions</CENTER></H2>
<A HREF="#3.1">3.1</A>) Why does initdb fail?<BR> <A HREF="#3.1">3.1</A>) Why does <I>initdb</I> fail?<BR>
<A HREF="#3.2">3.2</A>) How do I install PostgreSQL somewhere other than <A HREF="#3.2">3.2</A>) How do I install PostgreSQL somewhere other than
/usr/local/pgsql?<BR> /usr/local/pgsql?<BR>
<A HREF="#3.3">3.3</A>) When I start the postmaster, I get a <A HREF="#3.3">3.3</A>) When I start the postmaster, I get a
<I>Bad System Call</I> or core dumped message. Why?<BR> <I>Bad System Call</I> or core dumped message. Why?<BR>
<A HREF="#3.4">3.4</A>) When I try to start the postmaster, I get <A HREF="#3.4">3.4</A>) When I try to start the postmaster, I get
<I>IpcMemoryCreate</I> errors3. Why?<BR> <I>IpcMemoryCreate</I> errors. Why?<BR>
<A HREF="#3.5">3.5</A>) When I try to start the postmaster, I get <A HREF="#3.5">3.5</A>) When I try to start the postmaster, I get
<I>IpcSemaphoreCreate</I> errors. Why?<BR> <I>IpcSemaphoreCreate</I> errors. Why?<BR>
<A HREF="#3.6">3.6</A>) How do I prevent other hosts from accessing my <A HREF="#3.6">3.6</A>) How do I prevent other hosts from accessing my
@ -80,30 +81,29 @@ another machine?<BR>
table access. Why?<BR> table access. Why?<BR>
<A HREF="#3.10">3.10</A>) How do I tune the database engine for <A HREF="#3.10">3.10</A>) How do I tune the database engine for
better performance?<BR> better performance?<BR>
<A HREF="#3.11">3.11</A>) What debugging features are available in <A HREF="#3.11">3.11</A>) What debugging features are available?<BR>
PostgreSQL?<BR> <A HREF="#3.12">3.12</A>) I get <I>"Sorry, too many clients"</I> when trying to
<A HREF="#3.12">3.12</A>) I get 'Sorry, too many clients' when trying to
connect. Why?<BR> connect. Why?<BR>
<A HREF="#3.13">3.13</A>) What are the pg_psort.XXX files in my <A HREF="#3.13">3.13</A>) What are the <I>pg_sorttempNNN.NN</I> files in my
database directory?<BR> database directory?<BR>
<H2><CENTER>Operational Questions</CENTER></H2> <H2><CENTER>Operational Questions</CENTER></H2>
<A HREF="#4.1">4.1</A>) The system seems to be confused about commas, <A HREF="#4.1">4.1</A>) Why is the system confused about commas,
decimal points, and date formats.<BR> decimal points, and date formats.<BR>
<A HREF="#4.2">4.2</A>) What is the exact difference between <A HREF="#4.2">4.2</A>) What is the exact difference between
binary cursors and normal cursors?<BR> binary cursors and normal cursors?<BR>
<A HREF="#4.3">4.3</A>) How do I <I>select</I> only the first few rows of <A HREF="#4.3">4.3</A>) How do I <small>SELECT</small> only the first few rows of
a query?<BR> a query?<BR>
<A HREF="#4.4">4.4</A>) How do I get a list of tables, or other <A HREF="#4.4">4.4</A>) How do I get a list of tables or other
things I can see in <I>psql?</I><BR> things I can see in <I>psql?</I><BR>
<A HREF="#4.5">4.5</A>) How do you remove a column from a table?<BR> <A HREF="#4.5">4.5</A>) How do you remove a column from a table?<BR>
<A HREF="#4.6">4.6</A>) What is the maximum size for a <A HREF="#4.6">4.6</A>) What is the maximum size for a
row, table, database?<BR> row, table, database?<BR>
<A HREF="#4.7">4.7</A>) How much database disk space is required <A HREF="#4.7">4.7</A>) How much database disk space is required
to store data from a typical flat file?<BR> to store data from a typical text file?<BR>
<A HREF="#4.8">4.8</A>) How do I find out what indices or <A HREF="#4.8">4.8</A>) How do I find out what indices or
operations are defined in the database?<BR> operations are defined in the database?<BR>
@ -148,7 +148,7 @@ it in <I>psql,</I> why does it dump core?<BR>
<A HREF="#5.2">5.2</A>) What does the message: <A HREF="#5.2">5.2</A>) What does the message:
<I>NOTICE:PortalHeapMemoryFree: 0x402251d0 not in alloc set!</I> mean?<BR> <I>NOTICE:PortalHeapMemoryFree: 0x402251d0 not in alloc set!</I> mean?<BR>
<A HREF="#5.3">5.3</A>) How can I contribute some nifty new types and functions <A HREF="#5.3">5.3</A>) How can I contribute some nifty new types and functions
for PostgreSQL?<BR> to PostgreSQL?<BR>
<A HREF="#5.4">5.4</A>) How do I write a C function to return a <A HREF="#5.4">5.4</A>) How do I write a C function to return a
tuple?<BR> tuple?<BR>
<A HREF="#5.5">5.5</A>) I have changed a source file. Why does the <A HREF="#5.5">5.5</A>) I have changed a source file. Why does the
@ -171,8 +171,8 @@ PostgreSQL development is being performed by a team of Internet
developers who all subscribe to the PostgreSQL development mailing list. developers who all subscribe to the PostgreSQL development mailing list.
The current coordinator is Marc G. Fournier (<A The current coordinator is Marc G. Fournier (<A
HREF="mailto:scrappy@PostgreSQL.org">scrappy@PostgreSQL.org</A>). (See HREF="mailto:scrappy@PostgreSQL.org">scrappy@PostgreSQL.org</A>). (See
below on how to join). This team is now responsible for all current and below on how to join). This team is now responsible for all development
future development of PostgreSQL.<P> of PostgreSQL.<P>
The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. Many The authors of PostgreSQL 1.01 were Andrew Yu and Jolly Chen. Many
others have contributed to the porting, testing, debugging and others have contributed to the porting, testing, debugging and
@ -259,7 +259,7 @@ A file <I>win31.mak</I> is included in the distribution for making a
Win32 libpq library and psql.<P> Win32 libpq library and psql.<P>
The database server is now working on Windows NT using the Cygnus The database server is now working on Windows NT using the Cygnus
Unix/NT porting library. See pgsql/doc/README.NT in the distribution.<P> Unix/NT porting library. See <I>pgsql/doc/FAQ_NT</I> in the distribution.<P>
<H4><A NAME="1.5">1.5</A>) Where can I get PostgreSQL?</H4><P> <H4><A NAME="1.5">1.5</A>) Where can I get PostgreSQL?</H4><P>
@ -268,7 +268,7 @@ The primary anonymous ftp site for PostgreSQL is
HREF="ftp://ftp.PostgreSQL.org/pub">ftp://ftp.PostgreSQL.org/pub</A>. HREF="ftp://ftp.PostgreSQL.org/pub">ftp://ftp.PostgreSQL.org/pub</A>.
For mirror sites, see our main web site. For mirror sites, see our main web site.
<H4><A NAME="1.6">1.6</A>) Where can I get support for PostgreSQL?</H4><P> <H4><A NAME="1.6">1.6</A>) Where can I get support?</H4><P>
There is no official support for PostgreSQL from the University of There is no official support for PostgreSQL from the University of
California, Berkeley. It is maintained through volunteer effort.<P> California, Berkeley. It is maintained through volunteer effort.<P>
@ -334,31 +334,30 @@ Commercial support for PostgreSQL is available at <A
HREF="http://www.pgsql.com">http://www.pgsql.com/</A>.<P> HREF="http://www.pgsql.com">http://www.pgsql.com/</A>.<P>
<H4><A NAME="1.7">1.7</A>) What is the latest release of PostgreSQL?</H4><P> <H4><A NAME="1.7">1.7</A>) What is the latest release?</H4><P>
The latest release of PostgreSQL is version 7.0.2.<P> The latest release of PostgreSQL is version 7.0.2.<P>
We plan to have major releases every four months.<P> We plan to have major releases every four months.<P>
<H4><A NAME="1.8">1.8</A>) What documentation is available for PostgreSQL?</H4><P> <H4><A NAME="1.8">1.8</A>) What documentation is available?</H4><P>
Several manuals, manual pages, and some small test examples are Several manuals, manual pages, and some small test examples are
included in the distribution. See the /doc directory. You can also included in the distribution. See the /doc directory. You can also
browse the manual on-line at <A browse the manual on-line at <A
HREF="http://www.PostgreSQL.org/docs/postgres"> HREF="http://www.PostgreSQL.org/docs/postgres">
http://www.PostgreSQL.org/docs/postgres.</A> http://www.PostgreSQL.org/docs/postgres</A>.
in the distribution.
<P> <P>
There is a PostgreSQL book available at <A There is a PostgreSQL book available at <A
HREF="http://www.PostgreSQL.org/docs/awbook.html"> HREF="http://www.PostgreSQL.org/docs/awbook.html">
http://www.PostgreSQL.org/docs/awbook.html</A><P> http://www.PostgreSQL.org/docs/awbook.html</A>.<P>
<I>psql</I> has some nice \d commands to show information about types, <I>psql</I> has some nice \d commands to show information about types,
operators, functions, aggregates, etc.<P> operators, functions, aggregates, etc.<P>
The web site contains even more documentation.<P> Our web site contains even more documentation.<P>
<H4><A NAME="1.9">1.9</A>) How do I find out about known bugs or missing features? <H4><A NAME="1.9">1.9</A>) How do I find out about known bugs or missing features?
</H4><P> </H4><P>
@ -401,7 +400,7 @@ Second, subscribe to the pgsql-hackers and pgsql-patches mailing lists.
Third, submit high-quality patches to pgsql-patches.<P> Third, submit high-quality patches to pgsql-patches.<P>
There are about a dozen people who have commit privileges to There are about a dozen people who have commit privileges to
the PostgreSQL CVS archive. All of them have submitted so many the PostgreSQL CVS archive. They each have submitted so many
high-quality patches that it was a pain for the existing high-quality patches that it was a pain for the existing
committers to keep up, and we had confidence that patches they committers to keep up, and we had confidence that patches they
committed were likely to be of high quality. committed were likely to be of high quality.
@ -445,8 +444,7 @@ default modes. In <I>no-fsync</I> mode, we are usually faster than
commercial databases, though in this mode, an OS crash could cause data commercial databases, though in this mode, an OS crash could cause data
corruption. We are working to provide an intermediate mode that suffers corruption. We are working to provide an intermediate mode that suffers
less performance overhead than full fsync mode, and will allow data less performance overhead than full fsync mode, and will allow data
integrity within 30 seconds of an OS crash. The mode is select-able by integrity within 30 seconds of an OS crash.<BR><BR>
the database administrator.<BR><BR>
In comparison to MySQL or leaner database systems, we are slower on In comparison to MySQL or leaner database systems, we are slower on
inserts/updates because we have transaction overhead. Of course, MySQL inserts/updates because we have transaction overhead. Of course, MySQL
@ -502,8 +500,8 @@ in our BSD-style license stated above.<BR><BR>
There are two ODBC drivers available, PsqlODBC and OpenLink ODBC.<P> There are two ODBC drivers available, PsqlODBC and OpenLink ODBC.<P>
PsqlODBC is included in the distribution. More information about it can PsqlODBC is included in the distribution. More information about it can
be gotten from: <A HREF="ftp://ftp.PostgreSQL.org/pub/odbc/index.html"> be gotten from <A HREF="ftp://ftp.PostgreSQL.org/pub/odbc/">
ftp://ftp.PostgreSQL.org/pub/odbc/index.html</A><P> ftp://ftp.PostgreSQL.org/pub/odbc/</A>.<P>
OpenLink ODBC can be gotten from <A HREF="http://www.openlinksw.com/"> OpenLink ODBC can be gotten from <A HREF="http://www.openlinksw.com/">
http://www.openlinksw.com</A>. It works with their standard ODBC client http://www.openlinksw.com</A>. It works with their standard ODBC client
@ -528,7 +526,7 @@ HREF="http://www.webtools.com">http://www.webtools.com</A><P>
There is also one at <A HREF="http://www.phone.net/home/mwm/hotlist/"> There is also one at <A HREF="http://www.phone.net/home/mwm/hotlist/">
http://www.phone.net/home/mwm/hotlist/.</A><P> http://www.phone.net/home/mwm/hotlist/.</A><P>
For web integration, PHP is an excellent interface. It is at: For web integration, PHP is an excellent interface. It is at
<A HREF="http://www.php.net">http://www.php.net</A><P> <A HREF="http://www.php.net">http://www.php.net</A><P>
PHP is great for simple stuff, but for more complex cases, many PHP is great for simple stuff, but for more complex cases, many
@ -570,7 +568,7 @@ We have:
<H2><CENTER>Administrative Questions</CENTER></H2><P> <H2><CENTER>Administrative Questions</CENTER></H2><P>
<H4><A NAME="3.1">3.1</A>) Why does initdb fail?</H4><P> <H4><A NAME="3.1">3.1</A>) Why does <I>initdb</I> fail?</H4><P>
Try these: Try these:
<UL> <UL>
@ -600,7 +598,7 @@ kernel support for shared memory and semaphores.<P>
<H4><A NAME="3.4">3.4</A>) When I try to start the postmaster, I <H4><A NAME="3.4">3.4</A>) When I try to start the postmaster, I
get <I>IpcMemoryCreate</I> errors. Why?</H4><P> get <I>IpcMemoryCreate</I> errors. Why?</H4><P>
You either do not have shared memory configured properly in kernel or You either do not have shared memory configured properly in your kernel or
you need to enlarge the shared memory available in the kernel. The you need to enlarge the shared memory available in the kernel. The
exact amount you need depends on your architecture and how many buffers exact amount you need depends on your architecture and how many buffers
and backend processes you configure postmaster to run with. and backend processes you configure postmaster to run with.
@ -639,8 +637,7 @@ The default configuration allows only unix domain socket connections
from the local machine. To enable TCP/IP connections, make sure the from the local machine. To enable TCP/IP connections, make sure the
postmaster has been started with the <I>-i</I> option, and add an postmaster has been started with the <I>-i</I> option, and add an
appropriate host entry to the file appropriate host entry to the file
<I>pgsql/data/pg_hba.conf</I>. See the <I>pg_hba.conf</I> manual page.<P> <I>pgsql/data/pg_hba.conf</I>.
<H4><A NAME="3.8">3.8</A>) Why can't I access the database as the <I>root</I> <H4><A NAME="3.8">3.8</A>) Why can't I access the database as the <I>root</I>
user?</H4><P> user?</H4><P>
@ -666,7 +663,7 @@ allows you to see how PostgreSQL is interpreting your query, and which
indices are being used.<P> indices are being used.<P>
If you are doing a lot of <SMALL>INSERTs</SMALL>, consider doing them in a large If you are doing a lot of <SMALL>INSERTs</SMALL>, consider doing them in a large
batch using the <SMALL>COPY</SMALL> command. This is much faster than single batch using the <SMALL>COPY</SMALL> command. This is much faster than
individual <SMALL>INSERTS.</SMALL> Second, statements not in a <SMALL>BEGIN individual <SMALL>INSERTS.</SMALL> Second, statements not in a <SMALL>BEGIN
WORK/COMMIT</SMALL> transaction block are considered to be in their WORK/COMMIT</SMALL> transaction block are considered to be in their
own transaction. Consider performing several statements in a single own transaction. Consider performing several statements in a single
@ -675,12 +672,12 @@ consider dropping and recreating indices when making large data
changes.<P> changes.<P>
There are several tuning things that can be done. You can disable There are several tuning things that can be done. You can disable
fsync() by starting the postmaster with a <I>-o -F</I> option. This will <I>fsync()</I> by starting the postmaster with a <I>-o -F</I> option. This will
prevent <I>fsync()'s</I> from flushing to disk after every transaction.<P> prevent <I>fsync()'s</I> from flushing to disk after every transaction.<P>
You can also use the postmaster -B option to increase the number of You can also use the postmaster -B option to increase the number of
shared memory buffers used by the backend processes. If you make this shared memory buffers used by the backend processes. If you make this
parameter too high, the postmaster may not start up because you've exceeded parameter too high, the postmaster may not start because you've exceeded
your kernel's limit on shared memory space. your kernel's limit on shared memory space.
Each buffer is 8K and the default is 64 buffers.<P> Each buffer is 8K and the default is 64 buffers.<P>
@ -688,12 +685,11 @@ You can also use the backend -S option to increase the maximum amount
of memory used by the backend process for temporary sorts. The -S value of memory used by the backend process for temporary sorts. The -S value
is measured in kilobytes, and the default is 512 (ie, 512K).<P> is measured in kilobytes, and the default is 512 (ie, 512K).<P>
You can also use the <SMALL>CLUSTER</SMALL> command to group data in base tables to You can also use the <SMALL>CLUSTER</SMALL> command to group data in tables to
match an index. See the cluster(l) manual page for more details.<P> match an index. See the cluster(l) manual page for more details.<P>
<H4><A NAME="3.11">3.11</A>) What debugging features are available in <H4><A NAME="3.11">3.11</A>) What debugging features are available?</H4><P>
PostgreSQL?</H4><P>
PostgreSQL has several features that report status information that can PostgreSQL has several features that report status information that can
be valuable for debugging purposes.<P> be valuable for debugging purposes.<P>
@ -702,8 +698,8 @@ First, by running configure with the --enable-cassert option, many
<I>assert()'s</I> monitor the progress of the backend and halt the program when <I>assert()'s</I> monitor the progress of the backend and halt the program when
something unexpected occurs.<P> something unexpected occurs.<P>
Both postmaster and postgres have several debug options available. Both <I>postmaster</I> and <I>postgres</I> have several debug options available.
First, whenever you start the postmaster, make sure you send the First, whenever you start the <I>postmaster,</I> make sure you send the
standard output and error to a log file, like: standard output and error to a log file, like:
<PRE> <PRE>
cd /usr/local/pgsql cd /usr/local/pgsql
@ -712,17 +708,17 @@ standard output and error to a log file, like:
This will put a server.log file in the top-level PostgreSQL directory. This will put a server.log file in the top-level PostgreSQL directory.
This file contains useful information about problems or errors This file contains useful information about problems or errors
encountered by the server. Postmaster has a -d option that allows even encountered by the server. <I>Postmaster</I> has a -d option that allows even
more detailed information to be reported. The -d option takes a number more detailed information to be reported. The <I>-d</I> option takes a number
that specifies the debug level. Be warned that high debug level values that specifies the debug level. Be warned that high debug level values
generate large log files.<P> generate large log files.<P>
If the <i>postmaster</i> is not running, you can actually run the If the <i>postmaster</i> is not running, you can actually run the
postgres backend from the command line, and type your SQL statement <I>postgres</I> backend from the command line, and type your SQL statement
directly. This is recommended <B>only</B> for debugging purposes. Note directly. This is recommended <B>only</B> for debugging purposes. Note
that a newline terminates the query, not a semicolon. If you have that a newline terminates the query, not a semicolon. If you have
compiled with debugging symbols, you can use a debugger to see what is compiled with debugging symbols, you can use a debugger to see what is
happening. Because the backend was not started from the postmaster, it happening. Because the backend was not started from the <I>postmaster,</I> it
is not running in an identical environment and locking/backend is not running in an identical environment and locking/backend
interaction problems may not be duplicated.<P> interaction problems may not be duplicated.<P>
@ -735,12 +731,12 @@ you can set PGOPTIONS="-W n", then start <i>psql.</i> This will cause
startup to delay for <i>n</i> seconds so you can attach with the startup to delay for <i>n</i> seconds so you can attach with the
debugger and trace through the startup sequence.<P> debugger and trace through the startup sequence.<P>
The postgres program has -s, -A, and -t options that can be very useful The <I>postgres</I> program has <I>-s, -A,</I> and <I>-t</I> options that can be very useful
for debugging and performance measurements.<P> for debugging and performance measurements.<P>
You can also compile with profiling to see what functions are taking You can also compile with profiling to see what functions are taking
execution time. The backend profile files will be deposited in the execution time. The backend profile files will be deposited in the
pgsql/data/base/dbname directory. The client profile file will be put <I>pgsql/data/base/dbname</I> directory. The client profile file will be put
in the client's current directory.<P> in the client's current directory.<P>
@ -753,7 +749,7 @@ processes it can start.<P>
In PostgreSQL 6.5 and up, the default limit is 32 processes. You can In PostgreSQL 6.5 and up, the default limit is 32 processes. You can
increase it by restarting the postmaster with a suitable <I>-N</I> increase it by restarting the postmaster with a suitable <I>-N</I>
value. With the default configuration you can set <I>-N</I> as large as value. With the default configuration you can set <I>-N</I> as large as
1024; if you need more, increase <SMALL>MAXBACKENDS</SMALL> in 1024. If you need more, increase <SMALL>MAXBACKENDS</SMALL> in
<I>include/config.h</I> and rebuild. You can set the default value of <I>include/config.h</I> and rebuild. You can set the default value of
<I>-N</I> at configuration time, if you like, using configure's <I>-N</I> at configuration time, if you like, using configure's
<I>--with-maxbackends</I> switch.<P> <I>--with-maxbackends</I> switch.<P>
@ -769,23 +765,23 @@ check include the maximum size of shared memory blocks,
processes, <SMALL>NPROC,</SMALL> the maximum number of processes per processes, <SMALL>NPROC,</SMALL> the maximum number of processes per
user, <SMALL>MAXUPRC,</SMALL> and the maximum number of open files, user, <SMALL>MAXUPRC,</SMALL> and the maximum number of open files,
<SMALL>NFILE</SMALL> and <SMALL>NINODE.</SMALL> The reason that PostgreSQL <SMALL>NFILE</SMALL> and <SMALL>NINODE.</SMALL> The reason that PostgreSQL
has a limit on the number of allowed backend processes is so that you has a limit on the number of allowed backend processes is so
can ensure that your system won't run out of resources.<P> your system won't run out of resources.<P>
In PostgreSQL versions prior to 6.5, the maximum number of backends was In PostgreSQL versions prior to 6.5, the maximum number of backends was
64, and changing it required a rebuild after altering the MaxBackendId 64, and changing it required a rebuild after altering the MaxBackendId
constant in <I>include/storage/sinvaladt.h.</I><P> constant in <I>include/storage/sinvaladt.h.</I><P>
<H4><A NAME="3.13">3.13</A>) What are the pg_tempNNN.NN files in my <H4><A NAME="3.13">3.13</A>) What are the <I>pg_sorttempNNN.NN</I> files in my
database directory?</H4><P> database directory?</H4><P>
They are temporary files generated by the query executor. For They are temporary files generated by the query executor. For
example, if a sort needs to be done to satisfy an <SMALL>ORDER BY,</SMALL> and example, if a sort needs to be done to satisfy an <SMALL>ORDER BY,</SMALL> and
the sort requires more space than the backend's -S parameter allows, the sort requires more space than the backend's <I>-S</I> parameter allows,
then temp files are created to hold the extra data.<P> then temp files are created to hold the extra data.<P>
The temp files should go away automatically, but might not if a backend The temp files should be deleted automatically, but might not if a backend
crashes during a sort. If you have no transactions running at the time, crashes during a sort. If you have no backends running at the time,
it is safe to delete the pg_tempNNN.NN files.<P> it is safe to delete the pg_tempNNN.NN files.<P>
<HR> <HR>
@ -793,10 +789,10 @@ it is safe to delete the pg_tempNNN.NN files.<P>
<H2><CENTER>Operational Questions</CENTER></H2><P> <H2><CENTER>Operational Questions</CENTER></H2><P>
<H4><A NAME="4.1">4.1</A>) The system seems to be confused about <H4><A NAME="4.1">4.1</A>) Why is system confused about
commas, decimal points, and date formats.</H4><P> commas, decimal points, and date formats.</H4><P>
Check your locale configuration. PostgreSQL uses the locale settings of Check your locale configuration. PostgreSQL uses the locale setting of
the user that ran the postmaster process. There are postgres and psql the user that ran the postmaster process. There are postgres and psql
SET commands to control the date format. Set those accordingly for SET commands to control the date format. Set those accordingly for
your operating environment.<P> your operating environment.<P>
@ -819,13 +815,13 @@ 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 or the entire query may have to be evaluated until the desired rows have
been generated.<P> been generated.<P>
<H4><A NAME="4.4">4.4</A>) How do I get a list of tables, or other <H4><A NAME="4.4">4.4</A>) How do I get a list of tables or other
information I see in <I>psql?</I><BR></H4><P> things I can see in <I>psql?</I><BR></H4><P>
You can read the source code for <I>psql,</I> file You can read the source code for <I>psql</I> in file
pgsql/src/bin/psql/psql.c. It contains SQL commands that generate the <I>pgsql/src/bin/psql/psql.c.</I> It contains SQL commands that generate the
output for psql's backslash commands. You can also start <I>psql</I> output for psql's backslash commands. You can also start <I>psql</I>
with the <I>-E</I> option so that it will print out the queries it uses with the <I>-E</I> option so it will print out the queries it uses
to execute the commands you give.<P> to execute the commands you give.<P>
@ -870,9 +866,9 @@ Row length limit will be removed in 7.1.<P>
<H4><A NAME="4.7">4.7</A>)How much database disk space is required to <H4><A NAME="4.7">4.7</A>)How much database disk space is required to
store data from a typical flat file?<BR></H4><P> store data from a typical text file?<BR></H4><P>
A PostgreSQL database can require about six and a half times the disk space A PostgreSQL database may need six and a half times the disk space
required to store the data in a flat file.<P> required to store the data in a flat file.<P>
Consider a file of 300,000 lines with two integers on each line. The Consider a file of 300,000 lines with two integers on each line. The
@ -899,7 +895,7 @@ this data can be estimated at 14MB:
1755 database pages * 8192 bytes per page = 14,376,960 bytes (14MB) 1755 database pages * 8192 bytes per page = 14,376,960 bytes (14MB)
</PRE></P> </PRE></P>
Indexes do not contain as much overhead, but do contain the data that is Indexes do not require as much overhead, but do contain the data that is
being indexed, so they can be large also.<P> being indexed, so they can be large also.<P>
<H4><A NAME="4.8">4.8</A>) How do I find out what indices or <H4><A NAME="4.8">4.8</A>) How do I find out what indices or
@ -916,8 +912,8 @@ the database system tables.<P>
<H4><A NAME="4.9">4.9</A>) My queries are slow or don't make <H4><A NAME="4.9">4.9</A>) My queries are slow or don't make
use of the indexes. Why?</H4><P> use of the indexes. Why?</H4><P>
PostgreSQL does not automatically maintain statistics. One has to make PostgreSQL does not automatically maintain statistics. V<SMALL>ACUUM</SMALL>
an explicit <SMALL>VACUUM</SMALL> call to update the statistics. After must be run to update the statistics. After
statistics are updated, the optimizer knows how many rows in the table, statistics are updated, the optimizer knows how many rows in the table,
and can better decide if it should use indices. Note that the optimizer and can better decide if it should use indices. Note that the optimizer
does not use indices in cases when the table is small because a does not use indices in cases when the table is small because a
@ -972,15 +968,11 @@ documentation on how to do it.<P>
<H4><A NAME="4.12">4.12</A>) What is Genetic Query <H4><A NAME="4.12">4.12</A>) What is Genetic Query
Optimization?</H4><P> Optimization?</H4><P>
The GEQO module in PostgreSQL is intended to solve the query The GEQO module speeds query
optimization problem of joining many tables by means of a Genetic optimization when joining many tables by means of a Genetic
Algorithm (GA). It allows the handling of large join queries through Algorithm (GA). It allows the handling of large join queries through
non-exhaustive search.<P> non-exhaustive search.<P>
For further information see the documentation.
<H4><A NAME="4.13">4.13</A>) How do I do regular expression searches and <H4><A NAME="4.13">4.13</A>) How do I do regular expression searches and
case-insensitive regular expression searching?</H4><P> case-insensitive regular expression searching?</H4><P>
@ -1026,7 +1018,7 @@ first column of this type.<P>
<H4><A NAME="4.16.1">4.16.1</A>) How do I create a <H4><A NAME="4.16.1">4.16.1</A>) How do I create a
serial/auto-incrementing field?</H4><P> serial/auto-incrementing field?</H4><P>
PostgreSQL supports <SMALL>SERIAL</SMALL> data type. It auto-creates a PostgreSQL supports a <SMALL>SERIAL</SMALL> data type. It auto-creates a
sequence and index on the column. For example, this: sequence and index on the column. For example, this:
<PRE> <PRE>
CREATE TABLE person ( CREATE TABLE person (
@ -1052,14 +1044,14 @@ option or <SMALL>COPY WITH OIDS</SMALL> option to preserve the oids.<P>
<A HREF="http://www.PostgreSQL.org/docs/aw_pgsql_book">Numbering Rows.</A> <A HREF="http://www.PostgreSQL.org/docs/aw_pgsql_book">Numbering Rows.</A>
<H4><A NAME="4.16.2">4.16.2</A>) How do I get the back the generated SERIAL value after an insert?</H4><P> <H4><A NAME="4.16.2">4.16.2</A>) How do I get the back the generated SERIAL value after an insert?</H4><P>
Probably the simplest approach is to to retrieve the next SERIAL value from the sequence object with the <I>nextval()</I> function <I>before</I> inserting and then insert it explicitly. Using the example table in <A HREF="#4.16.1">4.16.1</A>, that might look like this: One approach is to to retrieve the next SERIAL value from the sequence object with the <I>nextval()</I> function <I>before</I> inserting and then insert it explicitly. Using the example table in <A HREF="#4.16.1">4.16.1</A>, that might look like this:
<PRE> <PRE>
$newSerialID = nextval('person_id_seq'); $newSerialID = nextval('person_id_seq');
INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal'); INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
</PRE> </PRE>
You would then also have the new value stored in <CODE>$newSerialID</CODE> for use in other queries (e.g., as a foreign key to the <CODE>person</CODE> table). Note that the name of the automatically-created SEQUENCE object will be named &lt<I>table</I>&gt_&lt<I>serialcolumn</I>&gt_<I>seq</I>, where <I>table</I> and <I>serialcolumn</I> are the names of your table and your SERIAL column, respectively. You would then also have the new value stored in <CODE>$newSerialID</CODE> for use in other queries (e.g., as a foreign key to the <CODE>person</CODE> table). Note that the name of the automatically-created SEQUENCE object will be named &lt<I>table</I>&gt_&lt<I>serialcolumn</I>&gt_<I>seq</I>, where <I>table</I> and <I>serialcolumn</I> are the names of your table and your SERIAL column, respectively.
<P> <P>
Similarly, you could retrieve the just-assigned SERIAL value with the <I>currval</I>() function <I>after</I> it was inserted by default, e.g., Alternatively, you could retrieve the just-assigned SERIAL value with the <I>currval</I>() function <I>after</I> it was inserted by default, e.g.,
<PRE> <PRE>
INSERT INTO person (name) VALUES ('Blaise Pascal'); INSERT INTO person (name) VALUES ('Blaise Pascal');
$newID = currval('person_id_seq'); $newID = currval('person_id_seq');
@ -1068,37 +1060,36 @@ Finally, you could use the <A HREF="#4.17">oid</A> returned from the
INSERT statement to lookup the default value, though this is probably INSERT statement to lookup the default value, though this is probably
the least portable approach. In perl, using DBI with Edmund Mergl's the least portable approach. In perl, using DBI with Edmund Mergl's
DBD::Pg module, the oid value is made available via DBD::Pg module, the oid value is made available via
$sth-&gt;{pg_oid_status} after $sth-&gt;execute(). <I>$sth-&gt;{pg_oid_status} after $sth-&gt;execute().</I>
<H4><A NAME="4.16.3">4.16.3</A>) Don't currval() and nextval() lead to a race condition with other <H4><A NAME="4.16.3">4.16.3</A>) Don't currval() and nextval() lead to a race condition with other
concurrent backend processes?</H4><P> concurrent backend processes?</H4><P>
No. That has been handled by the backends. No. This is handled by the backends.
<H4><A NAME="4.17">4.17</A>) What is an oid? What is a tid?</H4><P> <H4><A NAME="4.17">4.17</A>) What is an oid? What is a tid?</H4><P>
Oids are PostgreSQL's answer to unique row ids. Every row that is <small>OID</small>s are PostgreSQL's answer to unique row ids. Every row that is
created in PostgreSQL gets a unique oid. All oids generated during created in PostgreSQL gets a unique <small>oid</small>. All <small>oid</small>s generated during
initdb are less than 16384 (from <I>backend/access/transam.h</I>). All <I>initdb</I> are less than 16384 (from <I>backend/access/transam.h</I>). All
user-created oids are equal or greater that this. By default, all these user-created <small>oid</small>s are equal or greater that this. By default, all these
oids are unique not only within a table, or database, but unique within <small>oid</small>s are unique not only within a table, or database, but unique within
the entire PostgreSQL installation.<P> the entire PostgreSQL installation.<P>
PostgreSQL uses oids in its internal system tables to link rows between PostgreSQL uses <small>oid</small>s in its internal system tables to link rows between
tables. These oids can be used to identify specific user rows and used tables. These <small>oid</small>s can be used to identify specific user rows and used
in joins. It is recommended you use column type oid to store oid in joins. It is recommended you use column type <small>oid</small> to store <small>oid</small>
values. See the <I>sql(l)</I> manual page to see the other internal columns. values. You can create an index on the <small>oid</small> field for faster access.<P>
You can create an index on the oid field for faster access.<P>
Oids are assigned to all new rows from a central area that is used by <small>Oid</small>s are assigned to all new rows from a central area that is used by
all databases. If you want to change the oid to something else, or if all databases. If you want to change the <small>oid</small> to something else, or if
you want to make a copy of the table, with the original oid's, there is you want to make a copy of the table, with the original <small>oid</small>'s, there is
no reason you can't do it: no reason you can't do it:
<PRE> <PRE>
CREATE TABLE new_table(old_oid oid, mycol int); CREATE TABLE new_table(old_oid oid, mycol int);
SELECT INTO new SELECT old_oid, mycol FROM old; SELECT old_oid, mycol INTO new FROM old;
COPY new TO '/tmp/pgtable'; COPY new TO '/tmp/pgtable';
DELETE FROM new; DELETE FROM new;
COPY new WITH OIDS FROM '/tmp/pgtable'; COPY new WITH OIDS FROM '/tmp/pgtable';
@ -1162,13 +1153,11 @@ You need to put <CODE>BEGIN WORK</CODE> and <CODE>COMMIT
</CODE> around any use of a large object handle, that is, </CODE> around any use of a large object handle, that is,
surrounding <CODE>lo_open</CODE> ... <CODE>lo_close.</CODE><P> surrounding <CODE>lo_open</CODE> ... <CODE>lo_close.</CODE><P>
Current PostgreSQL enforces the rule by closing large object handles at Currently PostgreSQL enforces the rule by closing large object handles
transaction commit, which will be instantly upon completion of the at transaction commit. So the first attempt to do anything with the
<I>lo_open</I> command if you are not inside a transaction. So the handle will draw <I>invalid large obj descriptor.</I> So code that used
first attempt to do anything with the handle will draw <I>invalid large to work (at least most of the time) will now generate that error message
obj descriptor.</I> So code that used to work (at least most of the if you fail to use a transaction.<P>
time) will now generate that error message if you fail to use a
transaction.<P>
If you are using a client interface like ODBC you may need to set If you are using a client interface like ODBC you may need to set
<CODE>auto-commit off.</CODE><P> <CODE>auto-commit off.</CODE><P>
@ -1234,7 +1223,7 @@ Beware of mixing <I>malloc/free</I> and <I>palloc/pfree.</I>
<H4><A NAME="5.3">5.3</A>) How can I contribute some nifty new types and <H4><A NAME="5.3">5.3</A>) How can I contribute some nifty new types and
functions for PostgreSQL?</H4><P> functions to PostgreSQL?</H4><P>
Send your extensions to the pgsql-hackers mailing list, and they will Send your extensions to the pgsql-hackers mailing list, and they will