aboutsummaryrefslogtreecommitdiff
path: root/doc/FAQ
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-01-30 04:22:53 +0000
committerBruce Momjian <bruce@momjian.us>2005-01-30 04:22:53 +0000
commit8f2c03752bff0c47a617705dd96bd16a655b4e73 (patch)
tree295b458a31546541528e4b4ce29f7947b7ee1f95 /doc/FAQ
parent426ccf86fa6207f0715b576fe694339a45a12066 (diff)
downloadpostgresql-8f2c03752bff0c47a617705dd96bd16a655b4e73.tar.gz
postgresql-8f2c03752bff0c47a617705dd96bd16a655b4e73.zip
Backpatch FAQ changes to 8.0.X.
Diffstat (limited to 'doc/FAQ')
-rw-r--r--doc/FAQ368
1 files changed, 112 insertions, 256 deletions
diff --git a/doc/FAQ b/doc/FAQ
index 528ed9cb910..269a86447de 100644
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,7 +1,7 @@
Frequently Asked Questions (FAQ) for PostgreSQL
- Last updated: Wed Jan 19 14:45:22 EST 2005
+ Last updated: Sat Jan 29 23:20:03 EST 2005
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
@@ -16,85 +16,72 @@
1.1) What is PostgreSQL? How is it pronounced?
1.2) What is the copyright on PostgreSQL?
- 1.3) What Unix platforms does PostgreSQL run on?
- 1.4) What non-Unix ports are available?
- 1.5) Where can I get PostgreSQL?
- 1.6) Where can I get support?
- 1.7) What is the latest release?
- 1.8) What documentation is available?
- 1.9) How do I find out about known bugs or missing features?
- 1.10) How can I learn SQL?
- 1.11) Is PostgreSQL Y2K compliant?
- 1.12) How do I join the development team?
- 1.13) How do I submit a bug report?
- 1.14) How does PostgreSQL compare to other DBMSs?
- 1.15) How can I financially assist PostgreSQL?
+ 1.3) What platforms does PostgreSQL support?
+ 1.4) Where can I get PostgreSQL?
+ 1.5) Where can I get support?
+ 1.6) What is the latest release?
+ 1.7) What documentation is available?
+ 1.8) How do I find out about known bugs or missing features?
+ 1.9) How can I learn SQL?
+ 1.10) How do I join the development team?
+ 1.11) How do I submit a bug report?
+ 1.12) How does PostgreSQL compare to other DBMSs?
+ 1.13) How can I financially assist PostgreSQL?
User Client Questions
- 2.1) Are there ODBC drivers for PostgreSQL?
+ 2.1) What interfaces are available for PostgreSQL?
2.2) What tools are available for using PostgreSQL with Web pages?
2.3) Does PostgreSQL have a graphical user interface?
- 2.4) What languages are available to communicate with PostgreSQL?
Administrative Questions
3.1) How do I install PostgreSQL somewhere other than
/usr/local/pgsql?
- 3.2) When I start postmaster, I get a Bad System Call or core dumped
- message. Why?
- 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?
- 3.5) How do I control connections from other hosts?
- 3.6) How do I tune the database engine for better performance?
- 3.7) What debugging features are available?
- 3.8) Why do I get "Sorry, too many clients" when trying to connect?
- 3.9) What is in the pgsql_tmp directory?
- 3.10) Why do I need to do a dump and restore to upgrade PostgreSQL
+ 3.2) How do I control connections from other hosts?
+ 3.3) How do I tune the database engine for better performance?
+ 3.4) What debugging features are available?
+ 3.5) Why do I get "Sorry, too many clients" when trying to connect?
+ 3.6) What is in the pgsql_tmp directory?
+ 3.7) Why do I need to do a dump and restore to upgrade PostgreSQL
releases?
- 3.11) What computer hardware should I use?
+ 3.8) What computer hardware should I use?
Operational Questions
- 4.1) What is the difference between binary cursors and normal cursors?
- 4.2) How do I SELECT only the first few rows of a query? A random row?
- 4.3) How do I find out what tables, indexes, databases, and users are
+ 4.1) How do I SELECT only the first few rows of a query? A random row?
+ 4.2) How do I find out what tables, indexes, databases, and users are
defined? How do I see the queries used by psql to display them?
- 4.4) How do you remove a column from a table, or change its data type?
- 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.3) How do you remove a column from a table, or change its data type?
+ 4.4) What is the maximum size for a row, a table, and a database?
+ 4.5) How much database disk space is required to store data from a
typical text file?
- 4.7) My queries are slow or don't make use of the indexes. Why?
- 4.8) How do I see how the query optimizer is evaluating my query?
- 4.9) What is an R-tree index?
- 4.10) What is the Genetic Query Optimizer?
- 4.11) How do I perform regular expression searches and
- case-insensitive regular expression searches? How do I use an index
- for case-insensitive searches?
- 4.12) In a query, how do I detect if a field is NULL?
- 4.13) What is the difference between the various character types?
- 4.14.0) How do I create a serial/auto-incrementing field?
- 4.14.1) How do I get the value of a SERIAL insert?
- 4.14.2) Doesn't currval() lead to a race condition with other users?
- 4.14.3) Why aren't my sequence numbers reused on transaction abort?
+ 4.6) Why are my queries slow? Why don't they use my indexes?
+ 4.7) How do I see how the query optimizer is evaluating my query?
+ 4.8) How do I perform regular expression searches and case-insensitive
+ regular expression searches? How do I use an index for
+ case-insensitive searches?
+ 4.9) In a query, how do I detect if a field is NULL?
+ 4.10) What is the difference between the various character types?
+ 4.11.0) How do I create a serial/auto-incrementing field?
+ 4.11.1) How do I get the value of a SERIAL insert?
+ 4.11.2) Doesn't currval() lead to a race condition with other users?
+ 4.11.3) Why aren't my sequence numbers reused on transaction abort?
Why are there gaps in the numbering of my sequence/SERIAL column?
- 4.15) What is an OID? What is a TID?
- 4.16) What is the meaning of some of the terms used in PostgreSQL?
- 4.17) Why do I get the error "ERROR: Memory exhausted in
+ 4.12) What is an OID? What is a TID?
+ 4.13) What is the meaning of some of the terms used in PostgreSQL?
+ 4.14) Why do I get the error "ERROR: Memory exhausted in
AllocSetAlloc()"?
- 4.18) How do I tell what PostgreSQL version I am running?
- 4.19) Why does my large-object operations get "invalid large obj
+ 4.15) How do I tell what PostgreSQL version I am running?
+ 4.16) Why does my large-object operations get "invalid large obj
descriptor"?
- 4.20) How do I create a column that will default to the current time?
- 4.21) Why are my subqueries using IN so slow?
- 4.22) How do I perform an outer join?
- 4.23) How do I perform queries using multiple databases?
- 4.24) How do I return multiple rows or columns from a function?
- 4.25) Why can't I reliably create/drop temporary tables in PL/PgSQL
+ 4.17) How do I create a column that will default to the current time?
+ 4.18) How do I perform an outer join?
+ 4.19) How do I perform queries using multiple databases?
+ 4.20) How do I return multiple rows or columns from a function?
+ 4.21) Why can't I reliably create/drop temporary tables in PL/PgSQL
functions?
- 4.26) What encryption options are available?
+ 4.22) What encryption options are available?
Extending PostgreSQL
@@ -172,14 +159,12 @@
no restrictions on how the source code may be used. We like it and
have no intention of changing it.
- 1.3) What Unix platforms does PostgreSQL run on?
+ 1.3) What platforms does PostgreSQL support?
In general, any modern Unix-compatible platform should be able to run
PostgreSQL. The platforms that had received explicit testing at the
time of release are listed in the installation instructions.
- 1.4) What non-Unix ports are available?
-
Starting with version 8.0, PostgreSQL now runs natively on Microsoft
Windows NT-based operating systems like Win2000, WinXP, and Win2003. A
prepackaged installer is available at
@@ -191,12 +176,12 @@
http://hobbes.nmsu.edu/cgi-bin/h-search?sh=1&button=Search&key=postgre
SQL&stype=all&sort=type&dir=%2F.
- 1.5) Where can I get PostgreSQL?
+ 1.4) Where can I get PostgreSQL?
The primary anonymous ftp site for PostgreSQL is
ftp://ftp.PostgreSQL.org/pub. For mirror sites, see our main web site.
- 1.6) Where can I get support?
+ 1.5) Where can I get support?
The main mailing list is: pgsql-general@PostgreSQL.org. It is
available for discussion of matters pertaining to PostgreSQL. To
@@ -241,13 +226,13 @@
A list of commercial support companies is available at
http://techdocs.postgresql.org/companies.php.
- 1.7) What is the latest release?
+ 1.6) What is the latest release?
The latest release of PostgreSQL is version 8.0.0.
We plan to have major releases every six to eight months.
- 1.8) What documentation is available?
+ 1.7) What documentation is available?
Several manuals, manual pages, and some small test examples are
included in the distribution. See the /doc directory. You can also
@@ -267,12 +252,12 @@
Our web site contains even more documentation.
- 1.9) How do I find out about known bugs or missing features?
+ 1.8) How do I find out about known bugs or missing features?
PostgreSQL supports an extended subset of SQL-92. See our TODO list
for known bugs, missing features, and future plans.
- 1.10) How can I learn SQL?
+ 1.9) How can I learn SQL?
The PostgreSQL book at http://www.PostgreSQL.org/docs/awbook.html
teaches SQL. There is another PostgreSQL book at
@@ -288,11 +273,7 @@
et al., Addison-Wesley. Others like The Complete Reference SQL, Groff
et al., McGraw-Hill.
- 1.11) Is PostgreSQL Y2K compliant?
-
- Yes, we easily handle dates past the year 2000 AD, and before 2000 BC.
-
- 1.12) How do I join the development team?
+ 1.10) How do I join the development team?
First, download the latest source and read the PostgreSQL Developers
documentation on our web site, or in the distribution. Second,
@@ -305,7 +286,7 @@
and we had confidence that patches they committed were of high
quality.
- 1.13) How do I submit a bug report?
+ 1.11) How do I submit a bug report?
Visit the PostgreSQL bug form at
http://www.postgresql.org/support/submitbug.
@@ -313,7 +294,7 @@
Also check out our ftp site ftp://ftp.PostgreSQL.org/pub to see if
there is a more recent PostgreSQL version or patches.
- 1.14) How does PostgreSQL compare to other DBMSs?
+ 1.12) How does PostgreSQL compare to other DBMSs?
There are several ways of measuring software: features, performance,
reliability, support, and price.
@@ -353,14 +334,14 @@
community, manuals, and the source code often make PostgreSQL
support superior to other DBMSs. There is commercial
per-incident support available for those who need it. (See FAQ
- section 1.6.)
+ section 1.5.)
Price
We are free for all use, both commercial and non-commercial.
You can add our code to your product with no limitations,
except those outlined in our BSD-style license stated above.
- 1.15) How can I financially assist PostgreSQL?
+ 1.13) How can I financially assist PostgreSQL?
PostgreSQL has had a first-class infrastructure since we started in
1996. This is all thanks to Marc Fournier, who has created and managed
@@ -386,21 +367,17 @@
User Client Questions
- 2.1) Are there ODBC drivers for PostgreSQL?
+ 2.1) What interfaces are available for PostgreSQL?
- There are two ODBC drivers available, PsqlODBC and OpenLink ODBC.
-
- You can download PsqlODBC from
- http://gborg.postgresql.org/project/psqlodbc/projdisplay.php.
-
- OpenLink ODBC can be gotten from http://www.openlinksw.com. It works
- with their standard ODBC client software so you'll have PostgreSQL
- ODBC available on every client platform they support (Win, Mac, Unix,
- VMS).
+ The PostgreSQL install includes only the C and embedded C interfaces.
+ All other interfaces are independent projects that are downloaded
+ separately; being separate allows them to have their own release
+ schedule and development teams.
- They will probably be selling this product to people who need
- commercial-quality support, but a freeware version will always be
- available. Please send questions to postgres95@openlink.co.uk.
+ Some programming languages like PHP include an interface to
+ PostgreSQL. Interfaces for languages like Perl, TCL, Python, and many
+ others are available at http://gborg.postgresql.org in the
+ Drivers/Interfaces section and via Internet search.
2.2) What tools are available for using PostgreSQL with Web pages?
@@ -424,21 +401,6 @@
See http://techdocs.postgresql.org/guides/GUITools for a more detailed
list.
-
- 2.4) What languages are able to communicate with PostgreSQL?
-
- Most popular programming languages contain an interface to PostgreSQL.
- Check your programming language's list of extension modules.
-
- The following interfaces are included in the PostgreSQL distribution:
- * C (libpq)
- * Embedded C (ecpg)
- * Java (jdbc)
- * Python (PyGreSQL)
- * TCL (libpgtcl)
-
- Additional interfaces are available at http://gborg.postgresql.org in
- the Drivers/Interfaces section.
_________________________________________________________________
Administrative Questions
@@ -447,43 +409,7 @@
Specify the --prefix option when running configure.
- 3.2) When I start postmaster, I get a Bad System Call or core dumped
- message. Why?
-
- It could be a variety of problems, but first check to see that you
- have System V extensions installed in your kernel. PostgreSQL requires
- kernel support for shared memory and semaphores.
-
- 3.3) When I try to start postmaster, I get IpcMemoryCreate errors. Why?
-
- 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 exact amount you need depends on your architecture and how
- many buffers and backend processes you configure for postmaster. For
- most systems, with default numbers of buffers and processes, you need
- a minimum of ~1 MB. See the PostgreSQL Administrator's Guide/Server
- Run-time Environment/Managing Kernel Resources section for more
- detailed information about shared memory and semaphores.
-
- 3.4) When I try to start postmaster, I get IpcSemaphoreCreate errors. Why?
-
- If the error message is IpcSemaphoreCreate: semget failed (No space
- left on device) then your kernel is not configured with enough
- semaphores. Postgres needs one semaphore per potential backend
- process. A temporary solution is to start postmaster with a smaller
- limit on the number of backend processes. Use -N with a parameter less
- than the default of 32. A more permanent solution is to increase your
- 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
- support configured in your kernel at all. See the PostgreSQL
- Administrator's Guide for more detailed information about shared
- memory and semaphores.
-
- 3.5) How do I control connections from other hosts?
+ 3.2) How do I control connections from other hosts?
By default, PostgreSQL only allows connections from the local machine
using Unix domain sockets or TCP/IP connections. Other machines will
@@ -491,7 +417,7 @@
postgresql.conf and enable host-based authentication by modifying the
file $PGDATA/pg_hba.conf accordingly.
- 3.6) How do I tune the database engine for better performance?
+ 3.3) How do I tune the database engine for better performance?
Certainly, indexes can speed up queries. The EXPLAIN ANALYZE command
allows you to see how PostgreSQL is interpreting your query, and which
@@ -523,7 +449,7 @@
You can also use the CLUSTER command to group data in tables to match
an index. See the CLUSTER manual page for more details.
- 3.7) What debugging features are available?
+ 3.4) What debugging features are available?
PostgreSQL has several features that report status information that
can be valuable for debugging purposes.
@@ -578,7 +504,7 @@ log_*
in the client's current directory. Linux requires a compile with
-DLINUX_PROFILE for proper profiling.
- 3.8) Why do I get "Sorry, too many clients" when trying to connect?
+ 3.5) Why do I get "Sorry, too many clients" when trying to connect?
You need to increase postmaster's limit on how many concurrent backend
processes it can start.
@@ -598,7 +524,7 @@ log_*
that PostgreSQL has a limit on the number of allowed backend processes
is so your system won't run out of resources.
- 3.9) What is in the pgsql_tmp directory?
+ 3.6) What is in the pgsql_tmp directory?
This directory contains temporary files generated by the query
executor. For example, if a sort needs to be done to satisfy an ORDER
@@ -609,7 +535,7 @@ log_*
remain if a backend crashes during a sort. A stop and restart of the
postmaster will remove files from those directories.
- 3.10) Why do I need to do a dump and restore to upgrade between major
+ 3.7) Why do I need to do a dump and restore to upgrade between major
PostgreSQL releases?
The PostgreSQL team makes only small changes between minor releases,
@@ -624,7 +550,7 @@ log_*
script can be used to upgrade without a dump/restore. The release
notes mention whether pg_upgrade is available for the release.
- 3.11) What computer hardware should I use?
+ 3.8) What computer hardware should I use?
Because PC hardware is mostly compatible, people tend to believe that
all PC hardware is of equal quality. It is not. ECC RAM, SCSI, and
@@ -637,11 +563,7 @@ log_*
Operational Questions
- 4.1) What is the difference between binary cursors and normal cursors?
-
- See the DECLARE manual page for a description.
-
- 4.2) How do I SELECT only the first few rows of a query? A random row?
+ 4.1) How do I SELECT only the first few rows of a query? A random row?
See the FETCH manual page, or use SELECT ... LIMIT....
@@ -657,7 +579,7 @@ log_*
ORDER BY random()
LIMIT 1;
- 4.3) How do I find out what tables, indexes, databases, and users are
+ 4.2) How do I find out what tables, indexes, databases, and users are
defined? How do I see the queries used by psql to display them?
Use the \dt command to see tables in psql. For a complete list of
@@ -676,7 +598,7 @@ log_*
many of the SELECTs needed to get information from the database system
tables.
- 4.4) How do you remove a column from a table, or change its data type?
+ 4.3) How do you remove a column from a table, or change its data type?
DROP COLUMN functionality was added in release 7.3 with ALTER TABLE
DROP COLUMN. In earlier versions, you can do this:
@@ -702,7 +624,7 @@ log_*
You might then want to do VACUUM FULL tab to reclaim the disk space
used by the expired rows.
- 4.5) What is the maximum size for a row, a table, and a database?
+ 4.4) What is the maximum size for a row, a table, and a database?
These are the limits:
Maximum size for a database? unlimited (32 TB databases exist)
@@ -724,7 +646,7 @@ log_*
The maximum table size and maximum number of columns can be quadrupled
by increasing the default block size to 32k.
- 4.6) How much database disk space is required to store data from a typical
+ 4.5) How much database disk space is required to store data from a typical
text file?
A PostgreSQL database may require up to five times the disk space to
@@ -758,7 +680,7 @@ log_*
NULLs are stored as bitmaps, so they use very little space.
- 4.7) My queries are slow or don't make use of the indexes. Why?
+ 4.6) Why are my queries slow? Why don't they use my indexes?
Indexes are not automatically used by every query. Indexes are only
used if the table is larger than a minimum size, and the query selects
@@ -800,7 +722,7 @@ log_*
[a-e].
* Case-insensitive searches such as ILIKE and ~* do not utilize
indexes. Instead, use functional indexes, which are described in
- section 4.11.
+ section 4.10.
* The default C locale must be used during initdb because it is not
possible to know the next-greater character in a non-C locale. You
can create a special
@@ -813,40 +735,11 @@ LIKE
types exactly match the index's column types. This is particularly
true of int2, int8, and numeric column indexes.
- 4.8) How do I see how the query optimizer is evaluating my query?
+ 4.7) How do I see how the query optimizer is evaluating my query?
See the EXPLAIN manual page.
- 4.9) What is an R-tree index?
-
- An R-tree index is used for indexing spatial data. A hash index can't
- handle range searches. A B-tree index only handles range searches in a
- single dimension. R-trees can handle multi-dimensional data. For
- 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
- all points within a bounding rectangle."
-
- The canonical paper that describes the original R-tree design is:
-
- Guttman, A. "R-trees: A Dynamic Index Structure for Spatial
- Searching." Proceedings of the 1984 ACM SIGMOD Int'l Conf on Mgmt of
- Data, 45-57.
-
- You can also find this paper in Stonebraker's "Readings in Database
- Systems".
-
- Built-in R-trees can handle polygons and boxes. In theory, R-trees can
- be extended to handle higher number of dimensions. In practice,
- extending R-trees requires a bit of work and we don't currently have
- any documentation on how to do it.
-
- 4.10) What is the Genetic Query Optimizer?
-
- The GEQO module speeds query optimization when joining many tables by
- means of a Genetic Algorithm (GA). It allows the handling of large
- join queries through nonexhaustive search.
-
- 4.11) How do I perform regular expression searches and case-insensitive
+ 4.8) How do I perform regular expression searches and case-insensitive
regular expression searches? How do I use an index for case-insensitive
searches?
@@ -863,11 +756,11 @@ LIKE
functional index, it will be used:
CREATE INDEX tabindex ON tab (lower(col));
- 4.12) In a query, how do I detect if a field is NULL?
+ 4.9) In a query, how do I detect if a field is NULL?
You test the column with IS NULL and IS NOT NULL.
- 4.13) What is the difference between the various character types?
+ 4.10) What is the difference between the various character types?
Type Internal Name Notes
--------------------------------------------------
@@ -895,7 +788,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
particularly values that include NULL bytes. All the types described
here have similar performance characteristics.
- 4.14.1) How do I create a serial/auto-incrementing field?
+ 4.11.1) How do I create a serial/auto-incrementing field?
PostgreSQL supports a SERIAL data type. It auto-creates a sequence.
For example, this:
@@ -916,11 +809,11 @@ BYTEA bytea variable-length byte array (null-byte safe)
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.
- 4.14.2) How do I get the value of a SERIAL insert?
+ 4.11.2) How do I get the value of a SERIAL insert?
One approach is to retrieve the next SERIAL value from the sequence
object with the nextval() function before inserting and then insert it
- explicitly. Using the example table in 4.14.1, an example in a
+ explicitly. Using the example table in 4.11.1, an example in a
pseudo-language would look like this:
new_id = execute("SELECT nextval('person_id_seq')");
execute("INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal')");
@@ -942,52 +835,36 @@ BYTEA bytea variable-length byte array (null-byte safe)
billion. In Perl, using DBI with the DBD::Pg module, the oid value is
made available via $sth->{pg_oid_status} after $sth->execute().
- 4.14.3) Doesn't currval() lead to a race condition with other users?
+ 4.11.3) Doesn't currval() lead to a race condition with other users?
No. currval() returns the current value assigned by your backend, not
by all users.
- 4.14.4) Why aren't my sequence numbers reused on transaction abort? Why are
+ 4.11.4) Why aren't my sequence numbers reused on transaction abort? Why are
there gaps in the numbering of my sequence/SERIAL column?
To improve concurrency, sequence values are given out to running
transactions as needed and are not locked until the transaction
completes. This causes gaps in numbering from aborted transactions.
- 4.15) What is an OID? What is a TID?
+ 4.12) What is an OID? What is a TID?
- OIDs are PostgreSQL's answer to unique row ids. Every row that is
- created in PostgreSQL gets a unique OID. All OIDs generated during
- initdb are less than 16384 (from include/access/transam.h). All
- user-created OIDs are equal to or greater than this. By default, all
- these OIDs are unique not only within a table or database, but unique
- within the entire PostgreSQL installation.
-
- PostgreSQL uses OIDs in its internal system tables to link 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
- OID values. You can create an index on the OID field for faster
- access.
-
- 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
- you want to make a copy of the table, with the original OIDs, there is
- no reason you can't do it:
- CREATE TABLE new_table(mycol int);
- SELECT oid AS old_oid, mycol INTO tmp_table FROM old_table;
- COPY tmp_table TO '/tmp/pgtable';
- COPY new_table WITH OIDS FROM '/tmp/pgtable';
- DROP TABLE tmp_table;
-
- OIDs are stored as 4-byte integers, and will overflow at 4 billion. No
- one has reported this ever happening, and we plan to have the limit
- removed before anyone does.
+ Every row that is created in PostgreSQL gets a unique OID unless
+ created WITHOUT OIDS. OIDs are autotomatically assigned unique 4-byte
+ integers that are unique across the entire installation. However, they
+ overflow at 4 billion, and then the OIDs start being duplicated.
+ PostgreSQL uses OIDs to link its internal system tables together.
+
+ To uniquely number columns in user tables, it is best to use SERIAL
+ rather than OIDs because SERIAL sequences are unique only within a
+ single table. and are therefore less likely to overflow. SERIAL8 is
+ available for storing eight-byte sequence values.
TIDs are used to identify specific physical rows with block and offset
values. TIDs change after rows are modified or reloaded. They are used
by index entries to point to physical rows.
- 4.16) What is the meaning of some of the terms used in PostgreSQL?
+ 4.13) What is the meaning of some of the terms used in PostgreSQL?
Some of the source code and older documentation use terms that have
more common usage. Here are some:
@@ -1005,7 +882,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
http://hea-www.harvard.edu/MST/simul/software/docs/pkgs/pgsql/glossary
/glossary.html
- 4.17) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()"?
+ 4.14) Why do I get the error "ERROR: Memory exhausted in AllocSetAlloc()"?
You probably have run out of virtual memory on your system, or your
kernel has a low limit for certain resources. Try this before starting
@@ -1020,11 +897,11 @@ BYTEA bytea variable-length byte array (null-byte safe)
problem with the SQL client because the backend is returning too much
data, try it before starting the client.
- 4.18) How do I tell what PostgreSQL version I am running?
+ 4.15) How do I tell what PostgreSQL version I am running?
From psql, type SELECT version();
- 4.19) Why does my large-object operations get "invalid large obj
+ 4.16) 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
@@ -1039,33 +916,12 @@ BYTEA bytea variable-length byte array (null-byte safe)
If you are using a client interface like ODBC you may need to set
auto-commit off.
- 4.20) How do I create a column that will default to the current time?
+ 4.17) How do I create a column that will default to the current time?
Use CURRENT_TIMESTAMP:
CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
- 4.21) Why are my subqueries using IN so slow?
-
- In versions prior to 7.4, subqueries were joined to outer queries by
- sequentially scanning the result of the subquery for each row of the
- outer query. If the subquery returns only a few rows and the outer
- query returns many rows, IN is fastest. To speed up other queries,
- replace IN with EXISTS:
- SELECT *
- FROM tab
- WHERE col IN (SELECT subcol FROM subtab);
-
- to:
- SELECT *
- FROM tab
- WHERE EXISTS (SELECT subcol FROM subtab WHERE subcol = col);
-
- For this to be fast, subcol should be an indexed column.
-
- In version 7.4 and later, IN actually uses the same sophisticated join
- techniques as normal queries, and is prefered to using EXISTS.
-
- 4.22) How do I perform an outer join?
+ 4.18) How do I perform an outer join?
PostgreSQL supports outer joins using the SQL standard syntax. Here
are two examples:
@@ -1095,7 +951,7 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
ORDER BY col1
- 4.23) How do I perform queries using multiple databases?
+ 4.19) How do I perform queries using multiple databases?
There is no way to query a database other than the current one.
Because PostgreSQL loads database-specific system catalogs, it is
@@ -1105,12 +961,12 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
course, a client can make simultaneous connections to different
databases and merge the results on the client side.
- 4.24) How do I return multiple rows or columns from a function?
+ 4.20) How do I return multiple rows or columns from a function?
In 7.3, you can easily return multiple rows or columns from a
function, http://techdocs.postgresql.org/guides/SetReturningFunctions.
- 4.25) Why can't I reliably create/drop temporary tables in PL/PgSQL
+ 4.21) Why can't I reliably create/drop temporary tables in PL/PgSQL
functions?
PL/PgSQL caches function contents, and an unfortunate side effect is
@@ -1121,7 +977,7 @@ CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
table access in PL/PgSQL. This will cause the query to be reparsed
every time.
- 4.26) What encryption options are available?
+ 4.22) What encryption options are available?
* contrib/pgcrypto contains many encryption functions for use in SQL
queries.