|
|
|
@ -10,7 +10,7 @@ |
|
|
|
|
alink="#0000ff"> |
|
|
|
|
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1> |
|
|
|
|
|
|
|
|
|
<P>Last updated: Tue Nov 22 10:12:24 EST 2005</P> |
|
|
|
|
<P>Last updated: Tue Nov 22 10:16:48 EST 2005</P> |
|
|
|
|
|
|
|
|
|
<P>Current maintainer: Bruce Momjian (<A href= |
|
|
|
|
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>) |
|
|
|
@ -26,97 +26,97 @@ |
|
|
|
|
<HR> |
|
|
|
|
|
|
|
|
|
<H2 align="center">General Questions</H2> |
|
|
|
|
<A href="#1.1">1.1</A>) What is PostgreSQL? How is it pronounced?<BR> |
|
|
|
|
<A href="#1.2">1.2</A>) Who controls PostgreSQL?<BR> |
|
|
|
|
<A href="#1.3">1.3</A>) What is the copyright of PostgreSQL?<BR> |
|
|
|
|
<A href="#1.4">1.4</A>) What platforms does PostgreSQL support?<BR> |
|
|
|
|
<A href="#1.5">1.5</A>) Where can I get PostgreSQL?<BR> |
|
|
|
|
<A href="#1.6">1.6</A>) What is the latest release?<BR> |
|
|
|
|
<A href="#1.7">1.7</A>) Where can I get support?<BR> |
|
|
|
|
<A href="#1.8">1.8</A>) How do I submit a bug report?<BR> |
|
|
|
|
<A href="#1.9">1.9</A>) How do I find out about known bugs or |
|
|
|
|
<A href="#item1.1">1.1</A>) What is PostgreSQL? How is it pronounced?<BR> |
|
|
|
|
<A href="#item1.2">1.2</A>) Who controls PostgreSQL?<BR> |
|
|
|
|
<A href="#item1.3">1.3</A>) What is the copyright of PostgreSQL?<BR> |
|
|
|
|
<A href="#item1.4">1.4</A>) What platforms does PostgreSQL support?<BR> |
|
|
|
|
<A href="#item1.5">1.5</A>) Where can I get PostgreSQL?<BR> |
|
|
|
|
<A href="#item1.6">1.6</A>) What is the latest release?<BR> |
|
|
|
|
<A href="#item1.7">1.7</A>) Where can I get support?<BR> |
|
|
|
|
<A href="#item1.8">1.8</A>) How do I submit a bug report?<BR> |
|
|
|
|
<A href="#item1.9">1.9</A>) How do I find out about known bugs or |
|
|
|
|
missing features?<BR> |
|
|
|
|
<A href="#1.10">1.10</A>) What documentation is available?<BR> |
|
|
|
|
<A href="#1.11">1.11</A>) How can I learn <SMALL>SQL</SMALL>?<BR> |
|
|
|
|
<A href="#1.12">1.12</A>) How do I join the development team?<BR> |
|
|
|
|
<A href="#1.13">1.13</A>) How does PostgreSQL compare to other |
|
|
|
|
<A href="#item1.10">1.10</A>) What documentation is available?<BR> |
|
|
|
|
<A href="#item1.11">1.11</A>) How can I learn <SMALL>SQL</SMALL>?<BR> |
|
|
|
|
<A href="#item1.12">1.12</A>) How do I join the development team?<BR> |
|
|
|
|
<A href="#item1.13">1.13</A>) How does PostgreSQL compare to other |
|
|
|
|
<SMALL>DBMS</SMALL>s?<BR> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<H2 align="center">User Client Questions</H2> |
|
|
|
|
<A href="#2.1">2.1</A>) What interfaces are available for |
|
|
|
|
<A href="#item2.1">2.1</A>) What interfaces are available for |
|
|
|
|
PostgreSQL?<BR> |
|
|
|
|
<A href="#2.2">2.2</A>) What tools are available for using |
|
|
|
|
<A href="#item2.2">2.2</A>) What tools are available for using |
|
|
|
|
PostgreSQL with Web pages?<BR> |
|
|
|
|
<A href="#2.3">2.3</A>) Does PostgreSQL have a graphical user |
|
|
|
|
<A href="#item2.3">2.3</A>) Does PostgreSQL have a graphical user |
|
|
|
|
interface?<BR> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<H2 align="center">Administrative Questions</H2> |
|
|
|
|
<A href="#3.1">3.1</A>) How do I install PostgreSQL somewhere other |
|
|
|
|
<A href="#item3.1">3.1</A>) How do I install PostgreSQL somewhere other |
|
|
|
|
than <I>/usr/local/pgsql</I>?<BR> |
|
|
|
|
<A href="#3.2">3.2</A>) How do I control connections from other |
|
|
|
|
<A href="#item3.2">3.2</A>) How do I control connections from other |
|
|
|
|
hosts?<BR> |
|
|
|
|
<A href="#3.3">3.3</A>) How do I tune the database engine for |
|
|
|
|
<A href="#item3.3">3.3</A>) How do I tune the database engine for |
|
|
|
|
better performance?<BR> |
|
|
|
|
<A href="#3.4">3.4</A>) What debugging features are available?<BR> |
|
|
|
|
<A href="#3.5">3.5</A>) Why do I get <I>"Sorry, too many |
|
|
|
|
<A href="#item3.4">3.4</A>) What debugging features are available?<BR> |
|
|
|
|
<A href="#item3.5">3.5</A>) Why do I get <I>"Sorry, too many |
|
|
|
|
clients"</I> when trying to connect?<BR> |
|
|
|
|
<A href="#3.6">3.6</A>) Why do I need to do a dump and restore |
|
|
|
|
<A href="#item3.6">3.6</A>) Why do I need to do a dump and restore |
|
|
|
|
to upgrade PostgreSQL releases?<BR> |
|
|
|
|
<A href="#3.7">3.7</A>) What computer hardware should I use?<BR> |
|
|
|
|
<A href="#item3.7">3.7</A>) What computer hardware should I use?<BR> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<H2 align="center">Operational Questions</H2> |
|
|
|
|
<A href="#4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the |
|
|
|
|
<A href="#item4.1">4.1</A>) How do I <SMALL>SELECT</SMALL> only the |
|
|
|
|
first few rows of a query? A random row?<BR> |
|
|
|
|
<A href="#4.2">4.2</A>) How do I find out what tables, indexes, |
|
|
|
|
<A href="#item4.2">4.2</A>) How do I find out what tables, indexes, |
|
|
|
|
databases, and users are defined? How do I see the queries used |
|
|
|
|
by <I>psql</I> to display them?<BR> |
|
|
|
|
<A href="#4.3">4.3</A>) How do you change a column's data type?<BR> |
|
|
|
|
<A href="#4.4">4.4</A>) What is the maximum size for a row, a |
|
|
|
|
<A href="#item4.3">4.3</A>) How do you change a column's data type?<BR> |
|
|
|
|
<A href="#item4.4">4.4</A>) What is the maximum size for a row, a |
|
|
|
|
table, and a database?<BR> |
|
|
|
|
<A href="#4.5">4.5</A>) How much database disk space is required |
|
|
|
|
<A href="#item4.5">4.5</A>) How much database disk space is required |
|
|
|
|
to store data from a typical text file?<BR> |
|
|
|
|
<A href="#4.6">4.6</A>) Why are my queries slow? Why don't they |
|
|
|
|
<A href="#item4.6">4.6</A>) Why are my queries slow? Why don't they |
|
|
|
|
use my indexes?<BR> |
|
|
|
|
<A href="#4.7">4.7</A>) How do I see how the query optimizer is |
|
|
|
|
<A href="#item4.7">4.7</A>) How do I see how the query optimizer is |
|
|
|
|
evaluating my query?<BR> |
|
|
|
|
<A href="#4.8">4.8</A>) How do I perform regular expression |
|
|
|
|
<A href="#item4.8">4.8</A>) How do I perform regular expression |
|
|
|
|
searches and case-insensitive regular expression searches? How do I |
|
|
|
|
use an index for case-insensitive searches?<BR> |
|
|
|
|
<A href="#4.9">4.9</A>) In a query, how do I detect if a field |
|
|
|
|
<A href="#item4.9">4.9</A>) In a query, how do I detect if a field |
|
|
|
|
is <SMALL>NULL</SMALL>? How can I sort on whether a field is <SMALL> |
|
|
|
|
NULL</SMALL> or not?<BR> |
|
|
|
|
<A href="#4.10">4.10</A>) What is the difference between the |
|
|
|
|
<A href="#item4.10">4.10</A>) What is the difference between the |
|
|
|
|
various character types?<BR> |
|
|
|
|
<A href="#4.11.1">4.11.1</A>) How do I create a |
|
|
|
|
<A href="#item4.11.1">4.11.1</A>) How do I create a |
|
|
|
|
serial/auto-incrementing field?<BR> |
|
|
|
|
<A href="#4.11.2">4.11.2</A>) How do I get the value of a |
|
|
|
|
<A href="#item4.11.2">4.11.2</A>) How do I get the value of a |
|
|
|
|
<SMALL>SERIAL</SMALL> insert?<BR> |
|
|
|
|
<A href="#4.11.3">4.11.3</A>) Doesn't <I>currval()</I> |
|
|
|
|
<A href="#item4.11.3">4.11.3</A>) Doesn't <I>currval()</I> |
|
|
|
|
lead to a race condition with other users?<BR> |
|
|
|
|
<A href="#4.11.4">4.11.4</A>) Why aren't my sequence numbers |
|
|
|
|
<A href="#item4.11.4">4.11.4</A>) Why aren't my sequence numbers |
|
|
|
|
reused on transaction abort? Why are there gaps in the numbering of |
|
|
|
|
my sequence/SERIAL column?<BR> |
|
|
|
|
<A href="#4.12">4.12</A>) What is an <SMALL>OID</SMALL>? What is a |
|
|
|
|
<A href="#item4.12">4.12</A>) What is an <SMALL>OID</SMALL>? What is a |
|
|
|
|
<SMALL>CTID</SMALL>?<BR> |
|
|
|
|
<A href="#4.13">4.13</A>) Why do I get the error <I>"ERROR: Memory |
|
|
|
|
<A href="#item4.13">4.13</A>) Why do I get the error <I>"ERROR: Memory |
|
|
|
|
exhausted in AllocSetAlloc()"</I>?<BR> |
|
|
|
|
<A href="#4.14">4.14</A>) How do I tell what PostgreSQL version I |
|
|
|
|
<A href="#item4.14">4.14</A>) How do I tell what PostgreSQL version I |
|
|
|
|
am running?<BR> |
|
|
|
|
<A href="#4.15">4.15</A>) How do I create a column that will |
|
|
|
|
<A href="#item4.15">4.15</A>) How do I create a column that will |
|
|
|
|
default to the current time?<BR> |
|
|
|
|
<A href="#4.16">4.16</A>) How do I perform an outer join?<BR> |
|
|
|
|
<A href="#4.17">4.17</A>) How do I perform queries using multiple |
|
|
|
|
<A href="#item4.16">4.16</A>) How do I perform an outer join?<BR> |
|
|
|
|
<A href="#item4.17">4.17</A>) How do I perform queries using multiple |
|
|
|
|
databases?<BR> |
|
|
|
|
<A href="#4.18">4.18</A>) How do I return multiple rows or columns |
|
|
|
|
<A href="#item4.18">4.18</A>) How do I return multiple rows or columns |
|
|
|
|
from a function?<BR> |
|
|
|
|
<A href="#4.19">4.19</A>) Why do I get "relation with OID ##### |
|
|
|
|
<A href="#item4.19">4.19</A>) Why do I get "relation with OID ##### |
|
|
|
|
does not exist" errors when accessing temporary tables in PL/PgSQL |
|
|
|
|
functions?<BR> |
|
|
|
|
<A href="#4.20">4.20</A>) What replication solutions are available?<BR> |
|
|
|
|
<A href="#4.21">4.21</A>) Why are my table and column names not |
|
|
|
|
<A href="#item4.20">4.20</A>) What replication solutions are available?<BR> |
|
|
|
|
<A href="#item4.21">4.21</A>) Why are my table and column names not |
|
|
|
|
recognized in my query?<BR> |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ |
|
|
|
|
|
|
|
|
|
<H2 align="center">General Questions</H2> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.1">1.1) What is PostgreSQL? How is it pronounced?</H3> |
|
|
|
|
<H3 id="item1.1">1.1) What is PostgreSQL? How is it pronounced?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL is pronounced <I>Post-Gres-Q-L</I>, and is also sometimes |
|
|
|
|
referred to as just <I>Postgres</I>. An audio file is available in |
|
|
|
@ -145,7 +145,7 @@ |
|
|
|
|
http://www.postgresql.org/files/documentation/faqs/FAQ_DEV.html</A> |
|
|
|
|
</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.2">1.2) Who controls PostgreSQL?<BR></H3> |
|
|
|
|
<H3 id="item1.2">1.2) Who controls PostgreSQL?<BR></H3> |
|
|
|
|
|
|
|
|
|
<P>If you are looking for a PostgreSQL gatekeeper, central committee, |
|
|
|
|
or controlling company, give up --- there isn't one. We do have a |
|
|
|
@ -157,7 +157,7 @@ |
|
|
|
|
Developer's FAQ</A> for information on how to get involved in PostgreSQL |
|
|
|
|
development.)</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.3">1.3) What is the copyright of |
|
|
|
|
<H3 id="item1.3">1.3) What is the copyright of |
|
|
|
|
PostgreSQL?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL is distributed under the classic BSD license. Basically, |
|
|
|
@ -191,7 +191,7 @@ |
|
|
|
|
UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, |
|
|
|
|
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.4">1.4) What platforms does PostgreSQL support?</H3> |
|
|
|
|
<H3 id="item1.4">1.4) What platforms does PostgreSQL support?</H3> |
|
|
|
|
|
|
|
|
|
<P>In general, any modern Unix-compatible platform should be able to |
|
|
|
|
run PostgreSQL. The platforms that had received explicit testing at |
|
|
|
@ -210,21 +210,21 @@ |
|
|
|
|
"http://hobbes.nmsu.edu/cgi-bin/h-search?sh=1&button=Search&key=postgreSQL&stype=all&sort=type&dir=%2F"> |
|
|
|
|
http://hobbes.nmsu.edu/cgi-bin/h-search?sh=1&button=Search&key=postgreSQL&stype=all&sort=type&dir=%2F</a>.</p> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.5">1.5) Where can I get PostgreSQL?</H3> |
|
|
|
|
<H3 id="item1.5">1.5) Where can I get PostgreSQL?</H3> |
|
|
|
|
|
|
|
|
|
<P>Via web browser, use <a href="http://www.postgresql.org/ftp/"> |
|
|
|
|
http://www.postgresql.org/ftp/</a>, and via ftp, use |
|
|
|
|
<A href="ftp://ftp.PostgreSQL.org/pub/"> |
|
|
|
|
ftp://ftp.PostgreSQL.org/pub/</A>.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.6">1.6) What is the latest release?</H3> |
|
|
|
|
<H3 id="item1.6">1.6) What is the latest release?</H3> |
|
|
|
|
|
|
|
|
|
<P>The latest release of PostgreSQL is version 8.1.1</P> |
|
|
|
|
|
|
|
|
|
<P>We plan to have a major release every year, with minor releases |
|
|
|
|
every few months.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.7">1.7) Where can I get support?</H3> |
|
|
|
|
<H3 id="item1.7">1.7) Where can I get support?</H3> |
|
|
|
|
|
|
|
|
|
<P>The PostgreSQL community provides assistance to many of its users |
|
|
|
|
via email. The main web site to subscribe to the email lists is |
|
|
|
@ -243,7 +243,7 @@ |
|
|
|
|
"http://techdocs.postgresql.org/companies.php"> |
|
|
|
|
http://techdocs.postgresql.org/companies.php</A>.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.8">1.8) How do I submit a bug report?</H3> |
|
|
|
|
<H3 id="item1.8">1.8) How do I submit a bug report?</H3> |
|
|
|
|
|
|
|
|
|
<P>Visit the PostgreSQL bug form at <A href= |
|
|
|
|
"http://www.postgresql.org/support/submitbug"> |
|
|
|
@ -280,7 +280,7 @@ |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.9">1.9) How do I find out about known bugs or |
|
|
|
|
<H3 id="item1.9">1.9) How do I find out about known bugs or |
|
|
|
|
missing features?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL supports an extended subset of <SMALL>SQL:2003</SMALL>. |
|
|
|
@ -312,7 +312,7 @@ |
|
|
|
|
Even the release notes do not contain every change made to the |
|
|
|
|
software.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.10">1.10) What documentation is available?</H3> |
|
|
|
|
<H3 id="item1.10">1.10) What documentation is available?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL includes extensive documentation, including a large |
|
|
|
|
manual, manual pages, and some test examples. See the <I>/doc</I> |
|
|
|
@ -338,7 +338,7 @@ |
|
|
|
|
|
|
|
|
|
<P>Our web site contains even more documentation.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.11">1.11) How can I learn |
|
|
|
|
<H3 id="item1.11">1.11) How can I learn |
|
|
|
|
<SMALL>SQL</SMALL>?</H3> |
|
|
|
|
|
|
|
|
|
<P>First, consider the PostgreSQL-specific books mentioned above. |
|
|
|
@ -357,13 +357,13 @@ |
|
|
|
|
and at <A href= |
|
|
|
|
"http://sqlcourse.com/">http://sqlcourse.com.</A></P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.12">1.12) How do I join the development |
|
|
|
|
<H3 id="item1.12">1.12) How do I join the development |
|
|
|
|
team?</H3> |
|
|
|
|
|
|
|
|
|
<P>See the <a href="http://www.postgresql.org/docs/faqs.FAQ_DEV.html"> |
|
|
|
|
Developer's FAQ</A>.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="1.13">1.13) How does PostgreSQL compare to other |
|
|
|
|
<H3 id="item1.13">1.13) How does PostgreSQL compare to other |
|
|
|
|
<SMALL>DBMS</SMALL>s?</H3> |
|
|
|
|
|
|
|
|
|
<P>There are several ways of measuring software: features, |
|
|
|
@ -410,7 +410,7 @@ |
|
|
|
|
community, manuals, and the source code often make PostgreSQL |
|
|
|
|
support superior to other <SMALL>DBMS</SMALL>s. There is |
|
|
|
|
commercial per-incident support available for those who need it. |
|
|
|
|
(See <A href="#1.7">FAQ section 1.7</A>.)<BR> |
|
|
|
|
(See <A href="#item1.7">FAQ section 1.7</A>.)<BR> |
|
|
|
|
<BR> |
|
|
|
|
</DD> |
|
|
|
|
|
|
|
|
@ -427,7 +427,7 @@ |
|
|
|
|
|
|
|
|
|
<H2 align="center">User Client Questions</H2> |
|
|
|
|
|
|
|
|
|
<H3 ID="2.1">2.1) What interfaces are available for |
|
|
|
|
<H3 id="item2.1">2.1) What interfaces are available for |
|
|
|
|
PostgreSQL?</H3> |
|
|
|
|
|
|
|
|
|
<P>The PostgreSQL install includes only the <SMALL>C</SMALL> and embedded |
|
|
|
@ -442,7 +442,7 @@ |
|
|
|
|
in the <I>Drivers/Interfaces</I> section and via Internet search. |
|
|
|
|
</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="2.2">2.2) What tools are available for using |
|
|
|
|
<H3 id="item2.2">2.2) What tools are available for using |
|
|
|
|
PostgreSQL with Web pages?</H3> |
|
|
|
|
|
|
|
|
|
<P>A nice introduction to Database-backed Web pages can be seen at: |
|
|
|
@ -455,7 +455,7 @@ |
|
|
|
|
<P>For complex cases, many use the Perl and DBD::Pg with CGI.pm or |
|
|
|
|
mod_perl.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="2.3">2.3) Does PostgreSQL have a graphical user |
|
|
|
|
<H3 id="item2.3">2.3) Does PostgreSQL have a graphical user |
|
|
|
|
interface?</H3> |
|
|
|
|
|
|
|
|
|
<P>Yes, see <a href="http://techdocs.postgresql.org/guides/GUITools"> |
|
|
|
@ -467,13 +467,13 @@ |
|
|
|
|
|
|
|
|
|
<H2 align="center">Administrative Questions</H2> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.1">3.1) How do I install PostgreSQL somewhere |
|
|
|
|
<H3 id="item3.1">3.1) How do I install PostgreSQL somewhere |
|
|
|
|
other than <I>/usr/local/pgsql</I>?</H3> |
|
|
|
|
|
|
|
|
|
<P>Specify the <I>--prefix</I> option when running |
|
|
|
|
<I>configure</I>.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.2">3.2) How do I control connections from other |
|
|
|
|
<H3 id="item3.2">3.2) How do I control connections from other |
|
|
|
|
hosts?</H3> |
|
|
|
|
|
|
|
|
|
<P>By default, PostgreSQL only allows connections from the local |
|
|
|
@ -483,7 +483,7 @@ |
|
|
|
|
host-based authentication by modifying the |
|
|
|
|
<I>$PGDATA/pg_hba.conf</I> file, and restart the server.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.3">3.3) How do I tune the database engine for |
|
|
|
|
<H3 id="item3.3">3.3) How do I tune the database engine for |
|
|
|
|
better performance?</H3> |
|
|
|
|
|
|
|
|
|
<P>There are three major areas for potential performance |
|
|
|
@ -540,14 +540,14 @@ |
|
|
|
|
</DD> |
|
|
|
|
</DL> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.4">3.4) What debugging features are |
|
|
|
|
<H3 id="item3.4">3.4) What debugging features are |
|
|
|
|
available?</H3> |
|
|
|
|
|
|
|
|
|
<P>There are many <CODE>log_*</CODE> server configuration variables |
|
|
|
|
that enable printing of query and process statistics which can be |
|
|
|
|
very useful for debugging and performance measurements.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.5">3.5) Why do I get <I>"Sorry, too many |
|
|
|
|
<H3 id="item3.5">3.5) Why do I get <I>"Sorry, too many |
|
|
|
|
clients"</I> when trying to connect?</H3> |
|
|
|
|
|
|
|
|
|
<P>You have reached the default limit is 100 database sessions. You |
|
|
|
@ -556,7 +556,7 @@ |
|
|
|
|
<I>max_connections</I> value in <I>postgresql.conf</I> and |
|
|
|
|
restarting the <I>postmaster</I>.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.6">3.6) Why do I need to do a dump and restore |
|
|
|
|
<H3 id="item3.6">3.6) Why do I need to do a dump and restore |
|
|
|
|
to upgrade between major PostgreSQL releases?</H3> |
|
|
|
|
|
|
|
|
|
<P>The PostgreSQL team makes only small changes between minor releases, |
|
|
|
@ -567,7 +567,7 @@ |
|
|
|
|
data in a generic format that can then be loaded in using the new internal |
|
|
|
|
format.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="3.7">3.7) What computer hardware should I use?</H3> |
|
|
|
|
<H3 id="item3.7">3.7) What computer hardware should I use?</H3> |
|
|
|
|
|
|
|
|
|
<P>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 |
|
|
|
@ -581,7 +581,7 @@ |
|
|
|
|
|
|
|
|
|
<H2 align="center">Operational Questions</H2> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.1">4.1) How do I <SMALL>SELECT</SMALL> only the |
|
|
|
|
<H3 id="item4.1">4.1) How do I <SMALL>SELECT</SMALL> only the |
|
|
|
|
first few rows of a query? A random row?</H3> |
|
|
|
|
|
|
|
|
|
<P>To retrieve only a few rows, if you know at the number of rows |
|
|
|
@ -600,7 +600,7 @@ |
|
|
|
|
LIMIT 1; |
|
|
|
|
</PRE> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.2">4.2) How do I find out what tables, indexes, |
|
|
|
|
<H3 id="item4.2">4.2) How do I find out what tables, indexes, |
|
|
|
|
databases, and users are defined? How do I see the queries used |
|
|
|
|
by <I>psql</I> to display them?</H3> |
|
|
|
|
|
|
|
|
@ -623,7 +623,7 @@ |
|
|
|
|
illustrates many of the <SMALL>SELECT</SMALL>s needed to get |
|
|
|
|
information from the database system tables.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.3">4.3) How do you change a column's data type?</H3> |
|
|
|
|
<H3 id="item4.3">4.3) How do you change a column's data type?</H3> |
|
|
|
|
|
|
|
|
|
<P>Changing the data type of a column can be done easily in 8.0 |
|
|
|
|
and later with <SMALL>ALTER TABLE ALTER COLUMN TYPE</SMALL>.</P> |
|
|
|
@ -639,7 +639,7 @@ |
|
|
|
|
<P>You might then want to do <I>VACUUM FULL tab</I> to reclaim the |
|
|
|
|
disk space used by the expired rows.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.4">4.4) What is the maximum size for a row, a |
|
|
|
|
<H3 id="item4.4">4.4) What is the maximum size for a row, a |
|
|
|
|
table, and a database?</H3> |
|
|
|
|
|
|
|
|
|
<P>These are the limits:</P> |
|
|
|
@ -676,7 +676,7 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
of an MD5 hash of the long column, and full text indexing |
|
|
|
|
allows for searching of words within the column.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.5">4.5) How much database disk space is required |
|
|
|
|
<H3 id="item4.5">4.5) How much database disk space is required |
|
|
|
|
to store data from a typical text file?</H3> |
|
|
|
|
|
|
|
|
|
<P>A PostgreSQL database may require up to five times the disk |
|
|
|
@ -713,7 +713,7 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
<P><SMALL>NULL</SMALL>s are stored as bitmaps, so they |
|
|
|
|
use very little space.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.6">4.6) Why are my queries slow? Why don't they |
|
|
|
|
<H3 id="item4.6">4.6) Why are my queries slow? Why don't they |
|
|
|
|
use my indexes?</H3> |
|
|
|
|
|
|
|
|
|
<P>Indexes are not used by every query. Indexes are used only if the |
|
|
|
@ -764,7 +764,7 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
e.g. [a-e].</LI> |
|
|
|
|
<LI>Case-insensitive searches such as <SMALL>ILIKE</SMALL> and |
|
|
|
|
<I>~*</I> do not utilize indexes. Instead, use expression |
|
|
|
|
indexes, which are described in section <a href="#4.8">4.8</a>.</LI> |
|
|
|
|
indexes, which are described in section <a href="#item4.8">4.8</a>.</LI> |
|
|
|
|
<LI>The default <I>C</I> locale must be used during |
|
|
|
|
<i>initdb</i> because it is not possible to know the next-greatest |
|
|
|
|
character in a non-C locale. You can create a special |
|
|
|
@ -777,12 +777,12 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
types exactly match the index's column types. This was particularly |
|
|
|
|
true of int2, int8, and numeric column indexes.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.7">4.7) How do I see how the query optimizer is |
|
|
|
|
<H3 id="item4.7">4.7) How do I see how the query optimizer is |
|
|
|
|
evaluating my query?</H3> |
|
|
|
|
|
|
|
|
|
<P>See the <SMALL>EXPLAIN</SMALL> manual page.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.8">4.8) How do I perform regular expression |
|
|
|
|
<H3 id="item4.8">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?</H3> |
|
|
|
|
|
|
|
|
@ -809,7 +809,7 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
case to be stored in the column, use a <SMALL>CHECK</SMALL> |
|
|
|
|
constraint or a trigger.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.9">4.9) In a query, how do I detect if a field |
|
|
|
|
<H3 id="item4.9">4.9) In a query, how do I detect if a field |
|
|
|
|
is <SMALL>NULL</SMALL>? How can I sort on whether a field is <SMALL> |
|
|
|
|
NULL</SMALL> or not?</H3> |
|
|
|
|
|
|
|
|
@ -833,7 +833,7 @@ table?</TD><TD>unlimited</TD></TR> |
|
|
|
|
ORDER BY (col IS NOT NULL) |
|
|
|
|
</PRE> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.10">4.10) What is the difference between the |
|
|
|
|
<H3 id="item4.10">4.10) What is the difference between the |
|
|
|
|
various character types?</H3> |
|
|
|
|
<BLOCKQUOTE> |
|
|
|
|
<TABLE> |
|
|
|
@ -869,7 +869,7 @@ length</TD></TR> |
|
|
|
|
particularly values that include <SMALL>NULL</SMALL> bytes. All the |
|
|
|
|
types described here have similar performance characteristics.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.11.1">4.11.1) How do I create a |
|
|
|
|
<H3 id="item4.11.1">4.11.1) How do I create a |
|
|
|
|
serial/auto-incrementing field?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL supports a <SMALL>SERIAL</SMALL> data type. It |
|
|
|
@ -894,13 +894,13 @@ length</TD></TR> |
|
|
|
|
See the <I>create_sequence</I> manual page for more information |
|
|
|
|
about sequences. |
|
|
|
|
|
|
|
|
|
<H3 ID="4.11.2">4.11.2) How do I get the value of a |
|
|
|
|
<H3 id="item4.11.2">4.11.2) How do I get the value of a |
|
|
|
|
<SMALL>SERIAL</SMALL> insert?</H3> |
|
|
|
|
|
|
|
|
|
<P>One approach is to retrieve the next <SMALL>SERIAL</SMALL> 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.11.1">4.11.1</A>, an example in a |
|
|
|
|
example table in <A href="#item4.11.1">4.11.1</A>, an example in a |
|
|
|
|
pseudo-language would look like this:</P> |
|
|
|
|
<PRE> |
|
|
|
|
new_id = execute("SELECT nextval('person_id_seq')"); |
|
|
|
@ -923,13 +923,13 @@ length</TD></TR> |
|
|
|
|
new_id = execute("SELECT currval('person_id_seq')"); |
|
|
|
|
</PRE> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.11.3">4.11.3) Doesn't <I>currval()</I> |
|
|
|
|
<H3 id="item4.11.3">4.11.3) Doesn't <I>currval()</I> |
|
|
|
|
lead to a race condition with other users?</H3> |
|
|
|
|
|
|
|
|
|
<P>No. <I>currval()</I> returns the current value assigned by your |
|
|
|
|
session, not by all sessions.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.11.4">4.11.4) Why aren't my sequence numbers |
|
|
|
|
<H3 id="item4.11.4">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?</H3> |
|
|
|
|
|
|
|
|
@ -938,7 +938,7 @@ length</TD></TR> |
|
|
|
|
completes. This causes gaps in numbering from aborted |
|
|
|
|
transactions.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.12">4.12) What is an <SMALL>OID</SMALL>? What is |
|
|
|
|
<H3 id="item4.12">4.12) What is an <SMALL>OID</SMALL>? What is |
|
|
|
|
a <SMALL>CTID</SMALL>?</H3> |
|
|
|
|
|
|
|
|
|
<P>Every row that is created in PostgreSQL gets a unique |
|
|
|
@ -961,7 +961,7 @@ length</TD></TR> |
|
|
|
|
are modified or reloaded. They are used by index entries to point |
|
|
|
|
to physical rows.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.13">4.13) Why do I get the error <I>"ERROR: |
|
|
|
|
<H3 id="item4.13">4.13) Why do I get the error <I>"ERROR: |
|
|
|
|
Memory exhausted in AllocSetAlloc()"</I>?</H3> |
|
|
|
|
|
|
|
|
|
<P>You probably have run out of virtual memory on your system, |
|
|
|
@ -980,12 +980,12 @@ length</TD></TR> |
|
|
|
|
backend is returning too much data, try it before starting the |
|
|
|
|
client. |
|
|
|
|
|
|
|
|
|
<H3 ID="4.14">4.14) How do I tell what PostgreSQL version |
|
|
|
|
<H3 id="item4.14">4.14) How do I tell what PostgreSQL version |
|
|
|
|
I am running?</H3> |
|
|
|
|
|
|
|
|
|
<P>From <I>psql</I>, type <CODE>SELECT version();</CODE></P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.15">4.15) How do I create a column that will |
|
|
|
|
<H3 id="item4.15">4.15) How do I create a column that will |
|
|
|
|
default to the current time?</H3> |
|
|
|
|
|
|
|
|
|
<P>Use <I>CURRENT_TIMESTAMP</I>:</P> |
|
|
|
@ -993,7 +993,7 @@ length</TD></TR> |
|
|
|
|
CREATE TABLE test (x int, modtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); |
|
|
|
|
</PRE> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.16">4.16) How do I perform an outer join?</H3> |
|
|
|
|
<H3 id="item4.16">4.16) How do I perform an outer join?</H3> |
|
|
|
|
|
|
|
|
|
<P>PostgreSQL supports outer joins using the SQL standard syntax. |
|
|
|
|
Here are two examples:</P> |
|
|
|
@ -1016,7 +1016,7 @@ length</TD></TR> |
|
|
|
|
<SMALL>RIGHT</SMALL>, and <SMALL>FULL</SMALL> joins. Ordinary joins |
|
|
|
|
are called <SMALL>INNER</SMALL> joins.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.17">4.17) How do I perform queries using |
|
|
|
|
<H3 id="item4.17">4.17) How do I perform queries using |
|
|
|
|
multiple databases?</H3> |
|
|
|
|
|
|
|
|
|
<P>There is no way to query a database other than the current one. |
|
|
|
@ -1028,14 +1028,14 @@ length</TD></TR> |
|
|
|
|
connections to different databases and merge the results on the |
|
|
|
|
client side.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.18">4.18) How do I return multiple rows or |
|
|
|
|
<H3 id="item4.18">4.18) How do I return multiple rows or |
|
|
|
|
columns from a function?</H3> |
|
|
|
|
|
|
|
|
|
<P>It is easy using set-returning functions, |
|
|
|
|
<a href="http://techdocs.postgresql.org/guides/SetReturningFunctions"> |
|
|
|
|
http://techdocs.postgresql.org/guides/SetReturningFunctions</a></P>. |
|
|
|
|
|
|
|
|
|
<H3 ID="4.19">4.19) Why do I get "relation with OID ##### |
|
|
|
|
<H3 id="item4.19">4.19) Why do I get "relation with OID ##### |
|
|
|
|
does not exist" errors when accessing temporary tables in PL/PgSQL |
|
|
|
|
functions?</H3> |
|
|
|
|
|
|
|
|
@ -1047,7 +1047,7 @@ length</TD></TR> |
|
|
|
|
<SMALL>EXECUTE</SMALL> for temporary table access in PL/PgSQL. This |
|
|
|
|
will cause the query to be reparsed every time.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.20">4.20) What replication solutions are available? |
|
|
|
|
<H3 id="item4.20">4.20) What replication solutions are available? |
|
|
|
|
</H3> |
|
|
|
|
|
|
|
|
|
<P>Though "replication" is a single term, there are several technologies |
|
|
|
@ -1069,7 +1069,7 @@ length</TD></TR> |
|
|
|
|
<P>There are also commercial and hardware-based replication solutions |
|
|
|
|
available supporting a variety of replication models.</P> |
|
|
|
|
|
|
|
|
|
<H3 ID="4.21">4.21) Why are my table and column names not |
|
|
|
|
<H3 id="item4.21">4.21) Why are my table and column names not |
|
|
|
|
recognized in my query?</H3> |
|
|
|
|
|
|
|
|
|
<P>The most common cause is the use of double-quotes around table or |
|
|
|
|