Update FAQ.

This commit is contained in:
Bruce Momjian 2002-01-10 23:07:07 +00:00
parent 4c0e9b5efc
commit e19d7b7b95
2 changed files with 395 additions and 974 deletions

242
doc/FAQ
View File

@ -1,7 +1,7 @@
Frequently Asked Questions (FAQ) for PostgreSQL Frequently Asked Questions (FAQ) for PostgreSQL
Last updated: Fri Jan 4 00:44:42 EST 2002 Last updated: Thu Jan 10 18:07:03 EST 2002
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
@ -14,10 +14,10 @@
General Questions General Questions
1.1) What is PostgreSQL? 1.1) What is PostgreSQL? How is it pronounced?
1.2) What's the copyright on PostgreSQL? 1.2) What is the copyright on PostgreSQL?
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? 1.6) Where can I get support?
1.7) What is the latest release? 1.7) What is the latest release?
@ -27,13 +27,13 @@
1.11) Is PostgreSQL Y2K compliant? 1.11) Is PostgreSQL Y2K compliant?
1.12) How do I join the development team? 1.12) How do I join the development team?
1.13) How do I submit a bug report? 1.13) How do I submit a bug report?
1.14) How does PostgreSQL compare to other DBMS's? 1.14) How does PostgreSQL compare to other DBMSs?
1.15) How can I financially assist PostgreSQL? 1.15) How can I financially assist PostgreSQL?
User Client Questions User Client Questions
2.1) Are there ODBC drivers for PostgreSQL? 2.1) Are there ODBC drivers for PostgreSQL?
2.2) What tools are available for use PostgreSQL with Web pages? 2.2) What tools are available for using PostgreSQL with Web pages?
2.3) Does PostgreSQL have a graphical user interface? A report 2.3) Does PostgreSQL have a graphical user interface? A report
generator? An embedded query language interface? generator? An embedded query language interface?
2.4) What languages are available to communicate with PostgreSQL? 2.4) What languages are available to communicate with PostgreSQL?
@ -42,18 +42,18 @@
3.1) How do I install PostgreSQL somewhere other than 3.1) How do I install PostgreSQL somewhere other than
/usr/local/pgsql? /usr/local/pgsql?
3.2) When I start the postmaster, I get a Bad System Call or core 3.2) When I start postmaster, I get a Bad System Call or core dumped
dumped message. Why? message. Why?
3.3) When I try to start the postmaster, I get IpcMemoryCreate errors. 3.3) When I try to start postmaster, I get IpcMemoryCreate errors.
Why?
3.4) When I try to start postmaster, I get IpcSemaphoreCreate errors.
Why? Why?
3.4) When I try to start the postmaster, I get IpcSemaphoreCreate
errors. Why?
3.5) How do I prevent other hosts from accessing my PostgreSQL 3.5) How do I prevent other hosts from accessing my PostgreSQL
database? database?
3.6) Why can't I connect to my database from another machine? 3.6) Why can't I connect to my database from another machine?
3.7) How do I tune the database engine for better performance? 3.7) How do I tune the database engine for better performance?
3.8) What debugging features are available? 3.8) What debugging features are available?
3.9) I get "Sorry, too many clients" when trying to connect. Why? 3.9) Why do I get "Sorry, too many clients" when trying to connect?
3.10) What are the pg_sorttempNNN.NN files in my database directory? 3.10) What are the pg_sorttempNNN.NN files in my database directory?
Operational Questions Operational Questions
@ -62,7 +62,7 @@
4.2) 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?
4.3) 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?
4.4) How do you remove a column from a table? 4.4) How do you remove a column from a table?
4.5) What is the maximum size for a row, table, database? 4.5) What is the maximum size for a row, a table, and a database?
4.6) How much database disk space is required to store data from a 4.6) How much database disk space is required to store data from a
typical text file? typical text file?
4.7) 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
@ -83,10 +83,10 @@
4.16) What is an OID? What is a TID? 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.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 4.18) Why do I get the error "ERROR: Memory exhausted in
AllocSetAlloc()?" AllocSetAlloc()"?
4.19) How do I tell what PostgreSQL version I am running? 4.19) How do I tell what PostgreSQL version I am running?
4.20) My large-object operations get invalid large obj descriptor. 4.20) Why does my large-object operations get "invalid large obj
Why? descriptor"?
4.21) 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?
4.22) Why are my subqueries using IN so slow? 4.22) Why are my subqueries using IN so slow?
4.23) How do I perform an outer join? 4.23) How do I perform an outer join?
@ -99,7 +99,7 @@
5.2) How can I contribute some nifty new types and functions to 5.2) How can I contribute some nifty new types and functions to
PostgreSQL? PostgreSQL?
5.3) How do I write a C function to return a tuple? 5.3) How do I write a C function to return a tuple?
5.3) I have changed a source file. Why does the recompile not see the 5.4) I have changed a source file. Why does the recompile not see the
change? change?
_________________________________________________________________ _________________________________________________________________
@ -107,6 +107,8 @@
1.1) What is PostgreSQL? 1.1) What is PostgreSQL?
PostgreSQL is pronounced Post-Gres-Q-L.
PostgreSQL is an enhancement of the POSTGRES database management PostgreSQL is an enhancement of the POSTGRES database management
system, a next-generation DBMS research prototype. While PostgreSQL system, a next-generation DBMS research prototype. While PostgreSQL
retains the powerful data model and rich data types of POSTGRES, it retains the powerful data model and rich data types of POSTGRES, it
@ -131,15 +133,13 @@
functionality was added in 1995, its name was changed to Postgres95. functionality was added in 1995, its name was changed to Postgres95.
The name was changed at the end of 1996 to PostgreSQL. The name was changed at the end of 1996 to PostgreSQL.
It is pronounced Post-Gres-Q-L. 1.2) What is the copyright on PostgreSQL?
1.2) What's the copyright on PostgreSQL?
PostgreSQL is subject to the following COPYRIGHT: PostgreSQL is subject to the following COPYRIGHT:
PostgreSQL Data Base Management System PostgreSQL Data Base Management System
Portions copyright (c) 1996-2001, PostgreSQL Global Development Group Portions copyright (c) 1996-2002, PostgreSQL Global Development Group
Portions Copyright (c) 1994-6 Regents of the University of California Portions Copyright (c) 1994-6 Regents of the University of California
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
@ -167,7 +167,7 @@
PostgreSQL. The platforms that had received explicit testing at the PostgreSQL. The platforms that had received explicit testing at the
time of release are listed in the installation instructions. time of release are listed in the installation instructions.
1.4) What non-unix ports are available? 1.4) What non-Unix ports are available?
Client Client
@ -188,14 +188,14 @@
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? 1.6) Where can I get support?
The main mailing list is: pgsql-general@PostgreSQL.org. It is The main mailing list is: pgsql-general@PostgreSQL.org. It is
available for discussion of matters pertaining to PostgreSQL. To available for discussion of matters pertaining to PostgreSQL. To
subscribe, send mail with the following lines in the body (not the subscribe, send mail with the following lines in the body (not the
subject line) subject line):
subscribe subscribe
end end
@ -226,7 +226,7 @@
http://www.PostgreSQL.org http://www.PostgreSQL.org
There is also an IRC channel on EFNet, channel #PostgreSQL. I use the There is also an IRC channel on EFNet, channel #PostgreSQL. I use the
unix command irc -c '#PostgreSQL' "$USER" irc.phoenix.net. Unix command irc -c '#PostgreSQL' "$USER" irc.phoenix.net.
A list of commercial support companies is available at A list of commercial support companies is available at
http://www.postgresql.org/users-lounge/commercial-support.html. http://www.postgresql.org/users-lounge/commercial-support.html.
@ -250,7 +250,7 @@
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.
Our 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?
@ -261,7 +261,7 @@
The PostgreSQL book at http://www.PostgreSQL.org/docs/awbook.html The PostgreSQL book at http://www.PostgreSQL.org/docs/awbook.html
teaches SQL. There is a nice tutorial at teaches SQL. There is a nice tutorial at
http://w3.one.net/~jhoffman/sqltut.htm and at http://www.intermedia.net/support/sql/sqltut.shtm and at
http://ourworld.compuserve.com/homepages/graeme_birchall/HTM_COOK.HTM. http://ourworld.compuserve.com/homepages/graeme_birchall/HTM_COOK.HTM.
Another one is "Teach Yourself SQL in 21 Days, Second Edition" at Another one is "Teach Yourself SQL in 21 Days, Second Edition" at
@ -273,14 +273,14 @@
1.11) Is PostgreSQL Y2K compliant? 1.11) Is PostgreSQL Y2K compliant?
Yes, we easily handle dates past the year 2000AD, and before 2000BC. Yes, we easily handle dates past the year 2000 AD, and before 2000 BC.
1.12) How do I join the development team? 1.12) How do I join the development team?
First, download the latest source and read the PostgreSQL Developers First, download the latest source and read the PostgreSQL Developers
documentation on our Web site, or in the distribution. Second, documentation on our web site, or in the distribution. Second,
subscribe to the pgsql-hackers and pgsql-patches mailing lists. Third, subscribe to the pgsql-hackers and pgsql-patches mailing lists. Third,
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. They each have submitted so many high-quality PostgreSQL CVS archive. They each have submitted so many high-quality
@ -290,22 +290,22 @@
1.13) How do I submit a bug report? 1.13) How do I submit a bug report?
Fill out the "bug-template" file and send it to: Please visit the PostgreSQL BugTool page, which gives guidelines and
pgsql-bugs@PostgreSQL.org directions on how to submit a bug.
Also check out our ftp site ftp://ftp.PostgreSQL.org/pub to see if Also check out our ftp site ftp://ftp.PostgreSQL.org/pub to see if
there is a more recent PostgreSQL version or patches. there is a more recent PostgreSQL version or patches.
1.14) How does PostgreSQL compare to other DBMS's? 1.14) How does PostgreSQL compare to other DBMSs?
There are several ways of measuring software: features, performance, There are several ways of measuring software: features, performance,
reliability, support, and price. reliability, support, and price.
Features Features
PostgreSQL has most features present in large commercial PostgreSQL has most features present in large commercial DBMSs,
DBMS's, like transactions, subselects, triggers, views, foreign like transactions, subselects, triggers, views, foreign key
key referential integrity, and sophisticated locking. We have referential integrity, and sophisticated locking. We have some
some features they don't have, like user-defined types, features they do not have, like user-defined types,
inheritance, rules, and multi-version concurrency control to inheritance, rules, and multi-version concurrency control to
reduce lock contention. reduce lock contention.
@ -323,7 +323,7 @@
data integrity within 30 seconds of an OS crash. data integrity within 30 seconds of an OS crash.
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 does not have any of the features mentioned in
the Features section above. We are built for flexibility and the Features section above. We are built for flexibility and
features, though we continue to improve performance through features, though we continue to improve performance through
profiling and source code analysis. There is an interesting Web profiling and source code analysis. There is an interesting Web
@ -331,8 +331,8 @@
http://openacs.org/why-not-mysql.html http://openacs.org/why-not-mysql.html
We handle each user connection by creating a Unix process. We handle each user connection by creating a Unix process.
Backend processes share data buffers and locking information. Backend processes share data buffers and locking information.
With multiple CPU's, multiple backends can easily run on With multiple CPUs, multiple backends can easily run on
different CPU's. different CPUs.
Reliability Reliability
We realize that a DBMS must be reliable, or it is worthless. We We realize that a DBMS must be reliable, or it is worthless. We
@ -345,10 +345,10 @@
Support Support
Our mailing list provides a large group of developers and users Our mailing list provides a large group of developers and users
to help resolve any problems encountered. While we can not to help resolve any problems encountered. While we can not
guarantee a fix, commercial DBMS's don't always supply a fix guarantee a fix, commercial DBMSs do not always supply a fix
either. Direct access to developers, the user community, either. Direct access to developers, the user community,
manuals, and the source code often make PostgreSQL support manuals, and the source code often make PostgreSQL support
superior to other DBMS's. There is commercial per-incident superior to other DBMSs. There is commercial per-incident
support available for those who need it. (See support FAQ support available for those who need it. (See support FAQ
item.) item.)
@ -359,7 +359,7 @@
1.15) How can I financially assist PostgreSQL? 1.15) How can I financially assist PostgreSQL?
PostgreSQL has had a first-class infrastructure since we started five PostgreSQL has had a first-class infrastructure since we started six
years ago. This is all thanks to Marc Fournier, who has created and years ago. This is all thanks to Marc Fournier, who has created and
managed this infrastructure over the years. managed this infrastructure over the years.
@ -394,19 +394,19 @@
They will probably be selling this product to people who need They will probably be selling this product to people who need
commercial-quality support, but a freeware version will always be commercial-quality support, but a freeware version will always be
available. Questions to postgres95@openlink.co.uk. available. Please send questions to postgres95@openlink.co.uk.
See also the ODBC chapter of the Programmer's Guide. See also the ODBC chapter of the Programmer's Guide.
2.2) What tools are available for using PostgreSQL with Web pages? 2.2) What tools are available for using PostgreSQL with Web pages?
A nice introduction to Database-backed Web pages can be seen at: A nice introduction to Database-backed Web pages can be seen at:
http://www.webtools.com http://www.webreview.com
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.
For complex cases, many use the Perl interface and CGI.pm. For complex cases, many use the Perl interface and CGI.pm.
@ -414,7 +414,7 @@
An embedded query language interface? An embedded query language interface?
We have a nice graphical user interface called pgaccess, which is We have a nice graphical user interface called pgaccess, which is
shipped as part of the distribution. Pgaccess also has a report shipped as part of the distribution. pgaccess also has a report
generator. The Web page is http://www.flex.ro/pgaccess generator. The Web page is http://www.flex.ro/pgaccess
We also include ecpg, which is an embedded SQL query language We also include ecpg, which is an embedded SQL query language
@ -441,33 +441,35 @@
Specify the --prefix option when running configure. Specify the --prefix option when running configure.
3.2) When I start the postmaster, I get a Bad System Call or core dumped 3.2) When I start postmaster, I get a Bad System Call or core dumped
message. Why? message. Why?
It could be a variety of problems, but first check to see that you It could be a variety of problems, but first check to see that you
have System V extensions installed in your kernel. PostgreSQL requires have System V extensions installed in your kernel. PostgreSQL requires
kernel support for shared memory and semaphores. kernel support for shared memory and semaphores.
3.3) When I try to start the postmaster, I get IpcMemoryCreate errors. Why? 3.3) When I try to start postmaster, I get IpcMemoryCreate errors. Why?
You either do not have shared memory configured properly in your You either do not have shared memory configured properly in your
kernel or you need to enlarge the shared memory available in the kernel or you need to enlarge the shared memory available in the
kernel. The exact amount you need depends on your architecture and how kernel. The exact amount you need depends on your architecture and how
many buffers and backend processes you configure for the postmaster. many buffers and backend processes you configure for postmaster. For
For most systems, with default numbers of buffers and processes, you most systems, with default numbers of buffers and processes, you need
need a minimum of ~1MB. See the PostgreSQL Administrator's Guide for a minimum of ~1 MB. See the PostgreSQL Administrator's Guide for more
more detailed information about shared memory and semaphores. detailed information about shared memory and semaphores.
3.4) When I try to start the postmaster, I get IpcSemaphoreCreate errors. 3.4) When I try to start postmaster, I get IpcSemaphoreCreate errors. Why?
Why?
If the error message is IpcSemaphoreCreate: semget failed (No space If the error message is IpcSemaphoreCreate: semget failed (No space
left on device) then your kernel is not configured with enough left on device) then your kernel is not configured with enough
semaphores. Postgres needs one semaphore per potential backend semaphores. Postgres needs one semaphore per potential backend
process. A temporary solution is to start the postmaster with a process. A temporary solution is to start postmaster with a smaller
smaller limit on the number of backend processes. Use -N with a limit on the number of backend processes. Use -N with a parameter less
parameter less than the default of 32. A more permanent solution is to than the default of 32. A more permanent solution is to increase your
increase your kernel's SEMMNS and SEMMNI parameters. kernel's SEMMNS and SEMMNI parameters.
Inoperative semaphores can also cause crashes during heavy database
access.
If the error message is something else, you might not have semaphore If the error message is something else, you might not have semaphore
support configured in your kernel at all. See the PostgreSQL support configured in your kernel at all. See the PostgreSQL
@ -478,47 +480,44 @@
By default, PostgreSQL only allows connections from the local machine By default, PostgreSQL only allows connections from the local machine
using Unix domain sockets. Other machines will not be able to connect using Unix domain sockets. Other machines will not be able to connect
unless you add the -i flag to the postmaster, and enable host-based unless you add the -i flag to postmaster, and enable host-based
authentication by modifying the file $PGDATA/pg_hba.conf accordingly. authentication by modifying the file $PGDATA/pg_hba.conf accordingly.
This will allow TCP/IP connections. This will allow TCP/IP connections.
Inoperative semaphores can also cause crashes during heavy database
access.
3.6) Why can't I connect to my database from another machine? 3.6) Why can't I connect to my database from another machine?
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
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. host entry to the file pgsql/data/pg_hba.conf.
3.7) How do I tune the database engine for better performance? 3.7) How do I tune the database engine for better performance?
Certainly, indices can speed up queries. The EXPLAIN command allows Certainly, indexes can speed up queries. The EXPLAIN command allows
you to see how PostgreSQL is interpreting your query, and which you to see how PostgreSQL is interpreting your query, and which
indices are being used. indexes are being used.
If you are doing a lot of INSERTs, consider doing them in a large If you are doing many INSERTs, consider doing them in a large batch
batch using the COPY command. This is much faster than individual using the COPY command. This is much faster than individual INSERTS.
INSERTS. Second, statements not in a BEGIN WORK/COMMIT transaction Second, statements not in a BEGIN WORK/COMMIT transaction block are
block are considered to be in their own transaction. Consider considered to be in their own transaction. Consider performing several
performing several statements in a single transaction block. This statements in a single transaction block. This reduces the transaction
reduces the transaction overhead. Also consider dropping and overhead. Also, consider dropping and recreating indexes when making
recreating indices when making large data changes. large data changes.
There are several tuning options. You can disable fsync() by starting There are several tuning options. You can disable fsync() by starting
the postmaster with a -o -F option. This will prevent fsync()'s from postmaster with a -o -F option. This will prevent fsync()s from
flushing to disk after every transaction. flushing to disk after every transaction.
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 because you've parameter too high, the postmaster may not start because you have
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.
You can also use the backend -S option to increase the maximum amount 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 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 (i.e. 512K).
You can also use the CLUSTER command to group data in tables to match You can also use the CLUSTER command to group data in tables to match
an index. See the CLUSTER manual page for more details. an index. See the CLUSTER manual page for more details.
@ -529,12 +528,12 @@
can be valuable for debugging purposes. can be valuable for debugging purposes.
First, by running configure with the --enable-cassert option, many First, by running configure with the --enable-cassert option, many
assert()'s monitor the progress of the backend and halt the program assert()s monitor the progress of the backend and halt the program
when something unexpected occurs. when something unexpected occurs.
Both postmaster and postgres have several debug options available. Both postmaster and postgres have several debug options available.
First, whenever you start the postmaster, make sure you send the First, whenever you start postmaster, make sure you send the standard
standard output and error to a log file, like: output and error to a log file, like:
cd /usr/local/pgsql cd /usr/local/pgsql
./bin/postmaster >server.log 2>&1 & ./bin/postmaster >server.log 2>&1 &
@ -545,18 +544,18 @@
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. generate large log files.
If the postmaster is not running, you can actually run the postgres If postmaster is not running, you can actually run the postgres
backend from the command line, and type your SQL statement directly. backend from the command line, and type your SQL statement directly.
This is recommended only for debugging purposes. Note that a newline This is recommended only for debugging purposes. Note that a newline
terminates the query, not a semicolon. If you have compiled with terminates the query, not a semicolon. If you have compiled with
debugging symbols, you can use a debugger to see what is happening. debugging symbols, you can use a debugger to see what is happening.
Because the backend was not started from the postmaster, it is not Because the backend was not started from postmaster, it is not running
running in an identical environment and locking/backend interaction in an identical environment and locking/backend interaction problems
problems may not be duplicated. may not be duplicated.
If the postmaster is running, start psql in one window, then find the If postmaster is running, start psql in one window, then find the PID
PID of the postgres process used by psql. Use a debugger to attach to of the postgres process used by psql. Use a debugger to attach to the
the postgres PID. You can set breakpoints in the debugger and issue postgres PID. You can set breakpoints in the debugger and issue
queries from psql. If you are debugging postgres startup, you can set queries from psql. If you are debugging postgres startup, you can set
PGOPTIONS="-W n", then start psql. This will cause startup to delay PGOPTIONS="-W n", then start psql. This will cause startup to delay
for n seconds so you can attach to the process with the debugger, set for n seconds so you can attach to the process with the debugger, set
@ -570,13 +569,13 @@
pgsql/data/base/dbname directory. The client profile file will be put pgsql/data/base/dbname directory. The client profile file will be put
in the client's current directory. in the client's current directory.
3.9) I get 'Sorry, too many clients' when trying to connect. Why? 3.9) Why do I get "Sorry, too many clients" when trying to connect?
You need to increase the postmaster's limit on how many concurrent You need to increase postmaster's limit on how many concurrent backend
backend processes it can start. processes it can start.
The default limit is 32 processes. You can increase it by restarting The default limit is 32 processes. You can increase it by restarting
the postmaster with a suitable -N value or modifying postgresql.conf. postmaster with a suitable -N value or modifying postgresql.conf.
Note that if you make -N larger than 32, you must also increase -B Note that if you make -N larger than 32, you must also increase -B
beyond its default of 64; -B must be at least twice -N, and probably beyond its default of 64; -B must be at least twice -N, and probably
@ -639,13 +638,13 @@
DROP TABLE old_table; DROP TABLE old_table;
ALTER TABLE new_table RENAME TO old_table; ALTER TABLE new_table RENAME TO old_table;
4.5) What is the maximum size for a row, table, database? 4.5) What is the maximum size for a row, a table, and a database?
These are the limits: These are the limits:
Maximum size for a database? unlimited (60GB databases exist) Maximum size for a database? unlimited (60 GB databases exist)
Maximum size for a table? 16 TB Maximum size for a table? 16 TB
Maximum size for a row? unlimited in 7.1 and later Maximum size for a row? unlimited in 7.1 and later
Maximum size for a field? 1GB in 7.1 and later Maximum size for a field? 1 GB in 7.1 and later
Maximum number of rows in a table? unlimited Maximum number of rows in a table? unlimited
Maximum number of columns in a table? 250-1600 depending on column types Maximum number of columns in a table? 250-1600 depending on column types
Maximum number of indexes on a table? unlimited Maximum number of indexes on a table? unlimited
@ -654,8 +653,8 @@
disk space and memory/swap space. Performance may suffer when these disk space and memory/swap space. Performance may suffer when these
values get unusually large. values get unusually large.
The maximum table size of 16TB does not require large file support The maximum table size of 16 TB does not require large file support
from the operating system. Large tables are stored as multiple 1GB from the operating system. Large tables are stored as multiple 1 GB
files so file system size limits are not important. files so file system size limits are not important.
The maximum table size and maximum number of columns can be increased The maximum table size and maximum number of columns can be increased
@ -668,8 +667,8 @@
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.4 MB. The size of the PostgreSQL database file
containing this data can be estimated at 14MB: containing this data can be estimated at 14 MB:
36 bytes: each row header (approximate) 36 bytes: each row header (approximate)
+ 8 bytes: two int fields @ 4 bytes each + 8 bytes: two int fields @ 4 bytes each
+ 4 bytes: pointer on page to tuple + 4 bytes: pointer on page to tuple
@ -686,7 +685,7 @@
-------------------- = 1755 database pages -------------------- = 1755 database pages
171 rows per page 171 rows per page
1755 database pages * 8192 bytes per page = 14,376,960 bytes (14MB) 1755 database pages * 8192 bytes per page = 14,376,960 bytes (14 MB)
Indexes do not require 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.
@ -705,7 +704,7 @@
PostgreSQL does not automatically maintain statistics. VACUUM must be PostgreSQL does not automatically maintain statistics. VACUUM must be
run to update the statistics. After statistics are updated, the run to update the statistics. After statistics are updated, the
optimizer knows how many rows in the table, and can better decide if optimizer knows how many rows in the table, and can better decide if
it should use indices. Note that the optimizer does not use indices in it should use indexes. Note that the optimizer does not use indexes in
cases when the table is small because a sequential scan would be cases when the table is small because a sequential scan would be
faster. faster.
@ -720,9 +719,9 @@
followed by an explicit sort is faster than an indexscan of all tuples followed by an explicit sort is faster than an indexscan of all tuples
of a large table. This is because random disk access is very slow. of a large table. This is because random disk access is very slow.
When using wild-card operators such as LIKE or ~, indices can only be When using wild-card operators such as LIKE or ~, indexes can only be
used if the beginning of the search is anchored to the start of the used if the beginning of the search is anchored to the start of the
string. So, to use indices, LIKE searches should not begin with %, and string. So, to use indexes, LIKE searches should not begin with %, and
~(regular expression searches) should start with ^. ~(regular expression searches) should start with ^.
4.9) 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?
@ -733,7 +732,7 @@
An R-tree index is used for indexing spatial data. A hash index can't 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 handle range searches. A B-tree index only handles range searches in a
single dimension. R-tree's can handle multi-dimensional data. For single dimension. R-trees can handle multi-dimensional data. For
example, if an R-tree index can be built on an attribute of type example, if an R-tree index can be built on an attribute of type
point, the system can more efficiently answer queries such as "select point, the system can more efficiently answer queries such as "select
all points within a bounding rectangle." all points within a bounding rectangle."
@ -741,8 +740,8 @@
The canonical paper that describes the original R-tree design is: The canonical paper that describes the original R-tree design is:
Guttman, A. "R-trees: A Dynamic Index Structure for Spatial Guttman, A. "R-trees: A Dynamic Index Structure for Spatial
Searching." Proc of the 1984 ACM SIGMOD Int'l Conf on Mgmt of Data, Searching." Proceedings of the 1984 ACM SIGMOD Int'l Conf on Mgmt of
45-57. Data, 45-57.
You can also find this paper in Stonebraker's "Readings in Database You can also find this paper in Stonebraker's "Readings in Database
Systems". Systems".
@ -771,15 +770,13 @@
FROM tab FROM tab
WHERE lower(col) = 'abc' WHERE lower(col) = 'abc'
This will not use an standard index. However, if you create a This will not use an standard index. However, if you create a
functional index, it will be used: functional index, it will be used:
CREATE INDEX tabindex on tab (lower(col)); CREATE INDEX tabindex on tab (lower(col));
4.13) 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. You test the column with IS NULL and IS NOT NULL.
4.14) What is the difference between the various character types? 4.14) What is the difference between the various character types?
@ -828,22 +825,20 @@ BYTEA bytea variable-length byte array (null-safe)
However, if you need to dump and reload the database, you need to use However, if you need to dump and reload the database, you need to use
pg_dump's -o option or COPY WITH OIDS option to preserve the OIDs. pg_dump's -o option or COPY WITH OIDS option to preserve the OIDs.
Numbering Rows.
4.15.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 One approach is to retrieve the next SERIAL value from the sequence
object with the nextval() function before inserting and then insert it object with the nextval() function before inserting and then insert it
explicitly. Using the example table in 4.15.1, that might look like explicitly. Using the example table in 4.15.1, that might look like
this in Perl: this in Perl:
new_id = output of "SELECT nextval('person_id_seq')" new_id = output of "SELECT nextval('person_id_seq')"
INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal'); INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal');
You would then also have the new value stored in $newSerialID for use You would then also have the new value stored in new_id for use in
in other queries (e.g., as a foreign key to the person table). Note other queries (e.g., as a foreign key to the person table). Note that
that the name of the automatically created SEQUENCE object will be the name of the automatically created SEQUENCE object will be named
named <table>_<serialcolumn>_seq, where table and serialcolumn are the <table>_<serialcolumn>_seq, where table and serialcolumn are the names
names of your table and your SERIAL column, respectively. of your table and your SERIAL column, respectively.
Alternatively, you could retrieve the assigned SERIAL value with the Alternatively, you could retrieve the assigned SERIAL value with the
currval() function after it was inserted by default, e.g., currval() function after it was inserted by default, e.g.,
@ -877,10 +872,10 @@ BYTEA bytea variable-length byte array (null-safe)
OID values. You can create an index on the OID field for faster OID values. 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 OIDs, there is
is no reason you can't do it: 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 old_oid, mycol INTO new FROM old; SELECT old_oid, mycol INTO new FROM old;
COPY new TO '/tmp/pgtable'; COPY new TO '/tmp/pgtable';
@ -892,7 +887,7 @@ BYTEA bytea variable-length byte array (null-safe)
removed before anyone does. removed before anyone does.
TIDs are used to identify specific physical rows with block and offset TIDs are used to identify specific physical rows with block and offset
values. Tids change after rows are modified or reloaded. They are used values. TIDs change after rows are modified or reloaded. They are used
by index entries to point to physical rows. by index entries to point to physical rows.
4.17) 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?
@ -912,12 +907,12 @@ BYTEA bytea variable-length byte array (null-safe)
A list of general database terms can be found at: A list of general database terms can be found at:
http://www.comptechnews.com/~reaster/dbdesign.html http://www.comptechnews.com/~reaster/dbdesign.html
4.18) 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 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 problem. Also it is possible you have run out of virtual memory on
your system, or your kernel has a low limit for certain resources. Try your system, or your kernel has a low limit for certain resources. Try
this before starting the postmaster: this before starting postmaster:
ulimit -d 262144 ulimit -d 262144
limit datasize 256m limit datasize 256m
@ -932,7 +927,8 @@ BYTEA bytea variable-length byte array (null-safe)
From psql, type select version(); From psql, type select version();
4.20) My large-object operations get invalid large obj descriptor. Why? 4.20) Why does my large-object operations get "invalid large obj
descriptor"?
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.

File diff suppressed because it is too large Load Diff