Commit 2ba6cbc3 authored by Bruce Momjian's avatar Bruce Momjian

Mega-clarifications from Joachim Wieland.

parent 99b735cc
Frequently Asked Questions (FAQ) for PostgreSQL Frequently Asked Questions (FAQ) for PostgreSQL
Last updated: Sat Nov 27 00:14:59 EST 2004 Last updated: Sat Nov 27 23:55:37 EST 2004
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us) Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
...@@ -79,8 +79,7 @@ ...@@ -79,8 +79,7 @@
4.14) What is the difference between the various character types? 4.14) What is the difference between the various character types?
4.15.1) How do I create a serial/auto-incrementing field? 4.15.1) How do I create a serial/auto-incrementing field?
4.15.2) How do I get the value of a SERIAL insert? 4.15.2) How do I get the value of a SERIAL insert?
4.15.3) Don't currval() and nextval() lead to a race condition with 4.15.3) Doesn't currval() lead to a race condition with other users?
other users?
4.15.4) Why aren't my sequence numbers reused on transaction abort? 4.15.4) Why aren't my sequence numbers reused on transaction abort?
Why are there gaps in the numbering of my sequence/SERIAL column? Why are there gaps in the numbering of my sequence/SERIAL column?
4.16) What is an OID? What is a TID? 4.16) What is an OID? What is a TID?
...@@ -305,9 +304,8 @@ ...@@ -305,9 +304,8 @@
1.13) How do I submit a bug report? 1.13) How do I submit a bug report?
Please visit the PostgreSQL BugTool page at Visit the PostgreSQL bug form at
http://www.PostgreSQL.org/bugs/bugs.php, which gives guidelines and http://www.postgresql.org/bugform.html.
directions on how to submit a bug report.
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.
...@@ -420,10 +418,11 @@ ...@@ -420,10 +418,11 @@
Yes, there are several graphical interfaces to PostgreSQL available. Yes, there are several graphical interfaces to PostgreSQL available.
These include PgAccess http://www.pgaccess.org), PgAdmin III These include PgAccess http://www.pgaccess.org), PgAdmin III
(http://www.pgadmin.org, RHDB Admin (http://sources.redhat.com/rhdb/ ) (http://www.pgadmin.org, RHDB Admin (http://sources.redhat.com/rhdb/
and Rekall ( http://www.thekompany.com/products/rekall/, proprietary). ), TORA (http://www.globecom.net/tora/ (partly commercial), and Rekall
There is also PhpPgAdmin ( http://phppgadmin.sourceforge.net/ ), a ( http://www.thekompany.com/products/rekall/, proprietary). There is
web-based interface to PostgreSQL. also PhpPgAdmin ( http://phppgadmin.sourceforge.net/ ), a web-based
interface to PostgreSQL.
See http://techdocs.postgresql.org/guides/GUITools for a more detailed See http://techdocs.postgresql.org/guides/GUITools for a more detailed
list. list.
...@@ -464,7 +463,8 @@ ...@@ -464,7 +463,8 @@
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 postmaster. For many buffers and backend processes you configure for postmaster. For
most systems, with default numbers of buffers and processes, you need most systems, with default numbers of buffers and processes, you need
a minimum of ~1 MB. See the PostgreSQL Administrator's Guide for more 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. detailed information about shared memory and semaphores.
3.4) When I try to start postmaster, I get IpcSemaphoreCreate errors. Why? 3.4) When I try to start postmaster, I get IpcSemaphoreCreate errors. Why?
...@@ -507,19 +507,20 @@ ...@@ -507,19 +507,20 @@
overhead. Also, consider dropping and recreating indexes when making overhead. Also, consider dropping and recreating indexes when making
large data changes. large data changes.
There are several tuning options. You can disable fsync() by starting There are several tuning options in the Administration Guide/Server
postmaster with a -o -F option. This will prevent fsync()s from Run-time Environment/Run-time Configuration. You can disable fsync()
flushing to disk after every transaction. by using fsync option. This will prevent fsync()s from flushing to
disk after every transaction.
You can also use the postmaster -B option to increase the number of You can use the shared_buffers option to increase the number of shared
shared memory buffers used by the backend processes. If you make this memory buffers used by the backend processes. If you make this
parameter too high, the postmaster may not start because you have 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 1000 buffers.
You can also use the backend -S option to increase the maximum amount You can also use the sort_mem and work_mem options to increase the
of memory used by the backend process for temporary sorts. The -S maximum amount of memory used by the backend processes for each
value is measured in kilobytes, and the default is 512 (i.e. 512K). temporary sort. The default is 1024 (i.e. 1MB).
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.
...@@ -556,15 +557,22 @@ ...@@ -556,15 +557,22 @@
may not be duplicated. may not be duplicated.
If postmaster is running, start psql in one window, then find the PID If postmaster is running, start psql in one window, then find the PID
of the postgres process used by psql. Use a debugger to attach to the of the postgres process used by psql using
postgres PID. You can set breakpoints in the debugger and issue SELECT pg_backend_pid()
queries from psql. If you are debugging postgres startup, you can set
PGOPTIONS="-W n", then start psql. This will cause startup to delay . Use a debugger to attach to the postgres PID. You can set
for n seconds so you can attach to the process with the debugger, set breakpoints in the debugger and issue queries from psql. If you are
any breakpoints, and continue through the startup sequence. debugging postgres startup, you can set PGOPTIONS="-W n", then start
psql. This will cause startup to delay for n seconds so you can attach
The postgres program has -s, -A, and -t options that can be very to the process with the debugger, set any breakpoints, and continue
useful for debugging and performance measurements. through the startup sequence.
There are several
log_*
server configuration variables that enable printing of process
statistics which can be very useful for debugging and performance
measurements.
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
...@@ -795,7 +803,13 @@ ...@@ -795,7 +803,13 @@
* Case-insensitive searches such as ILIKE and ~* do not utilise * Case-insensitive searches such as ILIKE and ~* do not utilise
indexes. Instead, use functional indexes, which are described in indexes. Instead, use functional indexes, which are described in
section 4.12. section 4.12.
* The default C locale must be used during initdb. * 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
text_pattern_ops
index for such cases that work only for
LIKE
indexing.
In pre-8.0 releases, indexes often can not be used unless the data In pre-8.0 releases, indexes often can not be used unless the data
types exactly match the index's column types. This is particularly types exactly match the index's column types. This is particularly
...@@ -931,8 +945,7 @@ BYTEA bytea variable-length byte array (null-byte safe) ...@@ -931,8 +945,7 @@ BYTEA bytea variable-length byte array (null-byte safe)
oid value is made available via $sth->{pg_oid_status} after oid value is made available via $sth->{pg_oid_status} after
$sth->execute(). $sth->execute().
4.15.3) Don't currval() and nextval() lead to a race condition with other 4.15.3) Doesn't currval() lead to a race condition with other users?
users?
No. currval() returns the current value assigned by your backend, not No. currval() returns the current value assigned by your backend, not
by all users. by all users.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
alink="#0000ff"> alink="#0000ff">
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1> <H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
<P>Last updated: Sat Nov 27 00:14:59 EST 2004</P> <P>Last updated: Sat Nov 27 23:55:37 EST 2004</P>
<P>Current maintainer: Bruce Momjian (<A href= <P>Current maintainer: Bruce Momjian (<A href=
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR> "mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
...@@ -111,8 +111,8 @@ ...@@ -111,8 +111,8 @@
serial/auto-incrementing field?<BR> serial/auto-incrementing field?<BR>
<A href="#4.15.2">4.15.2</A>) How do I get the value of a <A href="#4.15.2">4.15.2</A>) How do I get the value of a
<SMALL>SERIAL</SMALL> insert?<BR> <SMALL>SERIAL</SMALL> insert?<BR>
<A href="#4.15.3">4.15.3</A>) Don't <I>currval()</I> and <A href="#4.15.3">4.15.3</A>) Doesn't <I>currval()</I>
<I>nextval()</I> lead to a race condition with other users?<BR> lead to a race condition with other users?<BR>
<A href="#4.15.4">4.15.4</A>) Why aren't my sequence numbers <A href="#4.15.4">4.15.4</A>) Why aren't my sequence numbers
reused on transaction abort? Why are there gaps in the numbering of reused on transaction abort? Why are there gaps in the numbering of
my sequence/SERIAL column?<BR> my sequence/SERIAL column?<BR>
...@@ -395,10 +395,9 @@ ...@@ -395,10 +395,9 @@
<H4><A name="1.13">1.13</A>) How do I submit a bug report?</H4> <H4><A name="1.13">1.13</A>) How do I submit a bug report?</H4>
<P>Please visit the PostgreSQL BugTool page at <A href= <P>Visit the PostgreSQL bug form at <A href=
"http://www.PostgreSQL.org/bugs/bugs.php">http://www.PostgreSQL.org/bugs/bugs.php</A>, "http://www.postgresql.org/bugform.html">
which gives guidelines and directions on how to submit a http://www.postgresql.org/bugform.html</A>.</P>
bug report.</P>
<P>Also check out our ftp site <A href= <P>Also check out our ftp site <A href=
"ftp://ftp.PostgreSQL.org/pub">ftp://ftp.PostgreSQL.org/pub</A> to "ftp://ftp.PostgreSQL.org/pub">ftp://ftp.PostgreSQL.org/pub</A> to
...@@ -546,7 +545,9 @@ ...@@ -546,7 +545,9 @@
http://www.pgaccess.org</a>), PgAdmin III (<a http://www.pgaccess.org</a>), PgAdmin III (<a
href="http://www.pgadmin.org">http://www.pgadmin.org</a>, RHDB Admin (<a href="http://www.pgadmin.org">http://www.pgadmin.org</a>, RHDB Admin (<a
href="http://sources.redhat.com/rhdb/">http://sources.redhat.com/rhdb/ href="http://sources.redhat.com/rhdb/">http://sources.redhat.com/rhdb/
</a>) and Rekall (<a href="http://www.thekompany.com/products/rekall/"> </a>), TORA (<a href="http://www.globecom.net/tora/">http://www.globecom.net/tora/
(partly commercial)</a>, and Rekall
(<a href="http://www.thekompany.com/products/rekall/">
http://www.thekompany.com/products/rekall/</a>, proprietary). There is http://www.thekompany.com/products/rekall/</a>, proprietary). There is
also PhpPgAdmin (<a href="http://phppgadmin.sourceforge.net/"> also PhpPgAdmin (<a href="http://phppgadmin.sourceforge.net/">
http://phppgadmin.sourceforge.net/ </a>), a web-based interface to http://phppgadmin.sourceforge.net/ </a>), a web-based interface to
...@@ -606,10 +607,9 @@ ...@@ -606,10 +607,9 @@
how many buffers and backend processes you configure for how many buffers and backend processes you configure for
<I>postmaster</I>. For most systems, with default numbers of <I>postmaster</I>. For most systems, with default numbers of
buffers and processes, you need a minimum of ~1 MB. See the <A buffers and processes, you need a minimum of ~1 MB. See the <A
href= href="http://www.postgresql.org/docs/current/static/kernel-resources.html">PostgreSQL
"http://www.PostgreSQL.org/docs/view.php?version=current&amp;idoc=1&amp;file=kernel-resources.html">PostgreSQL Administrator's Guide/Server Run-time Environment/Managing Kernel Resources</A>
Administrator's Guide</A> for more detailed information about section for more detailed information about shared memory and semaphores.</P>
shared memory and semaphores.</P>
<H4><A name="3.4">3.4</A>) When I try to start <I>postmaster</I>, I <H4><A name="3.4">3.4</A>) When I try to start <I>postmaster</I>, I
get <I>IpcSemaphoreCreate</I> errors. Why?</H4> get <I>IpcSemaphoreCreate</I> errors. Why?</H4>
...@@ -645,8 +645,9 @@ ...@@ -645,8 +645,9 @@
better performance?</H4> better performance?</H4>
<P>Certainly, indexes can speed up queries. The <P>Certainly, indexes can speed up queries. The
<SMALL>EXPLAIN ANALYZE</SMALL> command allows you to see how PostgreSQL is <SMALL>EXPLAIN ANALYZE</SMALL> command allows you to see how
interpreting your query, and which indexes are being used.</P> PostgreSQL is interpreting your query, and which indexes are
being used.</P>
<P>If you are doing many <SMALL>INSERTs</SMALL>, consider doing <P>If you are doing many <SMALL>INSERTs</SMALL>, consider doing
them in a large batch using the <SMALL>COPY</SMALL> command. This them in a large batch using the <SMALL>COPY</SMALL> command. This
...@@ -657,22 +658,23 @@ ...@@ -657,22 +658,23 @@
reduces the transaction overhead. Also, consider dropping and reduces the transaction overhead. Also, consider dropping and
recreating indexes when making large data changes.</P> recreating indexes when making large data changes.</P>
<P>There are several tuning options. You can disable <I>fsync()</I> <P>There are several tuning options in the <a href=
by starting <I>postmaster</I> with a <I>-o -F</I> option. This will "http://www.postgresql.org/docs/current/static/runtime.html">
Administration Guide/Server Run-time Environment/Run-time Configuration</a>.
You can disable <I>fsync()</I> by using <i>fsync</I> option. This will
prevent <I>fsync()</I>s from flushing to disk after every prevent <I>fsync()</I>s from flushing to disk after every
transaction.</P> transaction.</P>
<P>You can also use the <I>postmaster</I> <I>-B</I> option to <P>You can use the <I>shared_buffers</I> option to
increase the number of shared memory buffers used by the backend increase the number of shared memory buffers used by the backend
processes. If you make this parameter too high, the processes. If you make this parameter too high, the
<I>postmaster</I> may not start because you have exceeded your <I>postmaster</I> may not start because you have exceeded your
kernel's limit on shared memory space. Each buffer is 8K and the kernel's limit on shared memory space. Each buffer is 8K and the
default is 64 buffers.</P> default is 1000 buffers.</P>
<P>You can also use the backend <I>-S</I> option to increase the <P>You can also use the <I>sort_mem</I> and <I>work_mem</I> options
maximum amount of memory used by the backend process for temporary to increase the maximum amount of memory used by the backend processes
sorts. The <I>-S</I> value is measured in kilobytes, and the for each temporary sort. The default is 1024 (i.e. 1MB).</P>
default is 512 (i.e. 512K).</P>
<P>You can also use the <SMALL>CLUSTER</SMALL> command to group <P>You can also use the <SMALL>CLUSTER</SMALL> command to group
data in tables to match an index. See the <SMALL>CLUSTER</SMALL> data in tables to match an index. See the <SMALL>CLUSTER</SMALL>
...@@ -717,17 +719,18 @@ ...@@ -717,17 +719,18 @@
<P>If <I>postmaster</I> is running, start <I>psql</I> in one <P>If <I>postmaster</I> is running, start <I>psql</I> in one
window, then find the <SMALL>PID</SMALL> of the <I>postgres</I> window, then find the <SMALL>PID</SMALL> of the <I>postgres</I>
process used by <I>psql</I>. Use a debugger to attach to the process used by <I>psql</I> using <pre>SELECT pg_backend_pid()</pre>.
<I>postgres</I> <SMALL>PID</SMALL>. You can set breakpoints in the Use a debugger to attach to the <I>postgres</I> <SMALL>PID</SMALL>.
debugger and issue queries from <I>psql</I>. If you are debugging You can set breakpoints in the debugger and issue queries from
<I>postgres</I> startup, you can set PGOPTIONS="-W n", then start <I>psql</I>. If you are debugging <I>postgres</I> startup, you can
<I>psql</I>. This will cause startup to delay for <I>n</I> seconds set PGOPTIONS="-W n", then start <I>psql</I>. This will cause startup
so you can attach to the process with the debugger, set any to delay for <I>n</I> seconds so you can attach to the process with
breakpoints, and continue through the startup sequence.</P> the debugger, set any breakpoints, and continue through the startup
sequence.</P>
<P>The <I>postgres</I> program has <I>-s, -A</I>, and <I>-t</I>
options that can be very useful for debugging and performance <P>There are several <pre>log_*</pre> server configuration variables
measurements.</P> that enable printing of process statistics which can be very useful
for debugging and performance measurements.</P>
<P>You can also compile with profiling to see what functions are <P>You can also compile with profiling to see what functions are
taking execution time. The backend profile files will be deposited taking execution time. The backend profile files will be deposited
...@@ -947,7 +950,8 @@ ...@@ -947,7 +950,8 @@
<H4><A name="4.8">4.8</A>) My queries are slow or don't make use of <H4><A name="4.8">4.8</A>) My queries are slow or don't make use of
the indexes. Why?</H4> the indexes. Why?</H4>
Indexes are not automatically used by every query. Indexes are only
<P>Indexes are not automatically used by every query. Indexes are only
used if the table is larger than a minimum size, and the query used if the table is larger than a minimum size, and the query
selects only a small percentage of the rows in the table. This is selects only a small percentage of the rows in the table. This is
because the random disk access caused by an index scan can be because the random disk access caused by an index scan can be
...@@ -997,7 +1001,11 @@ ...@@ -997,7 +1001,11 @@
<I>~*</I> do not utilise indexes. Instead, use functional <I>~*</I> do not utilise indexes. Instead, use functional
indexes, which are described in section <a href="#4.12">4.12</a>.</LI> indexes, which are described in section <a href="#4.12">4.12</a>.</LI>
<LI>The default <I>C</I> locale must be used during <LI>The default <I>C</I> locale must be used during
<i>initdb</i>.</LI> <i>initdb</i> because it is not possible to know the next-greater
character in a non-C locale. You can create a special
<PRE>text_pattern_ops</PRE> index for such cases that work only
for <PRE>LIKE</PRE> indexing.
</LI>
</UL> </UL>
<P> <P>
...@@ -1169,8 +1177,8 @@ BYTEA bytea variable-length byte array (null-byte safe) ...@@ -1169,8 +1177,8 @@ BYTEA bytea variable-length byte array (null-byte safe)
value is made available via <I>$sth-&gt;{pg_oid_status}</I> after value is made available via <I>$sth-&gt;{pg_oid_status}</I> after
<I>$sth-&gt;execute()</I>. <I>$sth-&gt;execute()</I>.
<H4><A name="4.15.3">4.15.3</A>) Don't <I>currval()</I> and <H4><A name="4.15.3">4.15.3</A>) Doesn't <I>currval()</I>
<I>nextval()</I> lead to a race condition with other users?</H4> lead to a race condition with other users?</H4>
<P>No. <I>currval()</I> returns the current value assigned by your <P>No. <I>currval()</I> returns the current value assigned by your
backend, not by all users.</P> backend, not by all users.</P>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment