1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Create a GUC parameter temp_tablespaces that allows selection of the

tablespace(s) in which to store temp tables and temporary files.  This is a
list to allow spreading the load across multiple tablespaces (a random list
element is chosen each time a temp object is to be created).  Temp files are
not stored in per-database pgsql_tmp/ directories anymore, but per-tablespace
directories.

Jaime Casanova and Albert Cervera, with review by Bernd Helmle and Tom Lane.
This commit is contained in:
Tom Lane
2007-06-03 17:08:34 +00:00
parent 5d429f8d88
commit acfce502ba
26 changed files with 505 additions and 184 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.124 2007/05/17 23:36:04 neilc Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.125 2007/06/03 17:05:29 tgl Exp $ -->
<chapter Id="runtime-config">
<title>Server Configuration</title>
@ -281,7 +281,7 @@ SET ENABLE_SEQSCAN TO OFF;
If you wish, you can specify the configuration file names and locations
individually using the parameters <varname>config_file</>,
<varname>hba_file</> and/or <varname>ident_file</>.
<varname>config_file</> can only be specified on the
<varname>config_file</> can only be specified on the
<command>postgres</command> command line, but the others can be
set within the main configuration file. If all three parameters plus
<varname>data_directory</> are explicitly set, then it is not necessary
@ -311,7 +311,7 @@ SET ENABLE_SEQSCAN TO OFF;
<listitem>
<para>
Specifies the TCP/IP address(es) on which the server is
to listen for connections from client applications.
to listen for connections from client applications.
The value takes the form of a comma-separated list of host names
and/or numeric IP addresses. The special entry <literal>*</>
corresponds to all available IP interfaces.
@ -362,7 +362,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-superuser-reserved-connections"
xreflabel="superuser_reserved_connections">
<term><varname>superuser_reserved_connections</varname>
@ -461,7 +461,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-bonjour-name" xreflabel="bonjour_name">
<term><varname>bonjour_name</varname> (<type>string</type>)</term>
<indexterm>
@ -478,7 +478,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-tcp-keepalives-idle" xreflabel="tcp_keepalives_idle">
<term><varname>tcp_keepalives_idle</varname> (<type>integer</type>)</term>
<indexterm>
@ -494,7 +494,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-tcp-keepalives-interval" xreflabel="tcp_keepalives_interval">
<term><varname>tcp_keepalives_interval</varname> (<type>integer</type>)</term>
<indexterm>
@ -510,7 +510,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-tcp-keepalives-count" xreflabel="tcp_keepalives_count">
<term><varname>tcp_keepalives_count</varname> (<type>integer</type>)</term>
<indexterm>
@ -519,19 +519,19 @@ SET ENABLE_SEQSCAN TO OFF;
<listitem>
<para>
On systems that support the <symbol>TCP_KEEPCNT</symbol> socket option, specifies how
many keepalives can be lost before the connection is considered dead.
many keepalives can be lost before the connection is considered dead.
A value of zero uses the system default. If <symbol>TCP_KEEPCNT</symbol> is not
supported, this parameter must be zero. This parameter is ignored
for connections made via a Unix-domain socket.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="runtime-config-connection-security">
<title>Security and Authentication</title>
<variablelist>
<varlistentry id="guc-authentication-timeout" xreflabel="authentication_timeout">
<term><varname>authentication_timeout</varname> (<type>integer</type>)</term>
@ -826,7 +826,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-maintenance-work-mem" xreflabel="maintenance_work_mem">
<term><varname>maintenance_work_mem</varname> (<type>integer</type>)</term>
<indexterm>
@ -896,7 +896,7 @@ SET ENABLE_SEQSCAN TO OFF;
is not in the map cannot be re-used; instead <productname>PostgreSQL</>
will request more disk space from the operating system when it needs
to store new data.
The last few lines displayed by a database-wide <command>VACUUM VERBOSE</>
The last few lines displayed by a database-wide <command>VACUUM VERBOSE</>
command can help in determining if the current settings are adequate.
A <literal>NOTICE</> message is also printed during such an operation
if the current settings are too low.
@ -944,7 +944,7 @@ SET ENABLE_SEQSCAN TO OFF;
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="runtime-config-resource-kernel">
@ -3475,7 +3475,14 @@ SELECT * FROM parent WHERE key = 2400;
to specify using the default tablespace of the current database.
If the value does not match the name of any existing tablespace,
<productname>PostgreSQL</> will automatically use the default
tablespace of the current database.
tablespace of the current database. If a nondefault tablespace
is specified, the user must have <literal>CREATE</> privilege
for it, or creation attempts will fail.
</para>
<para>
This variable is not used for temporary tables; for them,
<xref linkend="guc-temp-tablespaces"> is consulted instead.
</para>
<para>
@ -3485,6 +3492,42 @@ SELECT * FROM parent WHERE key = 2400;
</listitem>
</varlistentry>
<varlistentry id="guc-temp-tablespaces" xreflabel="temp_tablespaces">
<term><varname>temp_tablespaces</varname> (<type>string</type>)</term>
<indexterm>
<primary><varname>temp_tablespaces</> configuration parameter</primary>
</indexterm>
<indexterm><primary>tablespace</><secondary>temporary</></>
<listitem>
<para>
This variable specifies tablespace(s) in which to create temporary
objects (temp tables and indexes on temp tables) when a
<command>CREATE</> command does not explicitly specify a tablespace.
Temporary files for purposes such as sorting large data sets
are also created in these tablespace(s).
</para>
<para>
The value is a list of names of tablespaces. When there is more than
one name in the list, <productname>PostgreSQL</> chooses a random
member of the list each time a temporary object is to be created.
</para>
<para>
If any element of the list is an empty string or does not match the
name of any existing tablespace, <productname>PostgreSQL</> will
automatically use the default tablespace of the current database
instead. If a nondefault tablespace
is specified, the user must have <literal>CREATE</> privilege
for it, or creation attempts will fail.
</para>
<para>
See also <xref linkend="guc-default-tablespace">.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-check-function-bodies" xreflabel="check_function_bodies">
<term><varname>check_function_bodies</varname> (<type>boolean</type>)</term>
<indexterm>
@ -3605,7 +3648,7 @@ SELECT * FROM parent WHERE key = 2400;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-xmlbinary" xreflabel="xmlbinary">
<term><varname>xmlbinary</varname> (<type>string</type>)</term>
<indexterm>
@ -3632,7 +3675,7 @@ SELECT * FROM parent WHERE key = 2400;
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-xmloption" xreflabel="xmloption">
<term><varname>xmloption</varname> (<type>string</type>)</term>
<indexterm>
@ -3664,7 +3707,7 @@ SET XML OPTION { DOCUMENT | CONTENT };
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 id="runtime-config-client-format">
@ -3945,7 +3988,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-local-preload-libraries" xreflabel="local_preload_libraries">
<term><varname>local_preload_libraries</varname> (<type>string</type>)</term>
<indexterm>
@ -3994,7 +4037,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
<para>
Every PostgreSQL-supported library has a <quote>magic
block</> that is checked to guarantee compatibility.
For this reason, non-PostgreSQL libraries cannot be
For this reason, non-PostgreSQL libraries cannot be
loaded in this way.
</para>
</listitem>

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.53 2007/02/01 00:28:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.54 2007/06/03 17:05:52 tgl Exp $ -->
<chapter id="managing-databases">
<title>Managing Databases</title>
@ -423,13 +423,23 @@ CREATE TABLE foo(i int);
do not have an explicit one.
</para>
<para>
There is also a <xref linkend="guc-temp-tablespaces"> parameter, which
determines the placement of temporary tables and indexes, as well as
temporary files that are used for purposes such as sorting large data
sets. This can be a list of tablespace names, rather than only one,
so that the load associated with temporary objects can be spread over
multiple tablespaces. A random member of the list is picked each time
a temporary object is to be created.
</para>
<para>
The tablespace associated with a database is used to store the system
catalogs of that database, as well as any temporary files created by
server processes using that database. Furthermore, it is the default
tablespace selected for tables and indexes created within the database,
if no <literal>TABLESPACE</> clause is given (either explicitly or via
<varname>default_tablespace</>) when the objects are created.
catalogs of that database. Furthermore, it is the default tablespace
used for tables, indexes, and temporary files created within the database,
if no <literal>TABLESPACE</> clause is given and no other selection is
specified by <varname>default_tablespace</> or
<varname>temp_tablespaces</> (as appropriate).
If a database is created without specifying a tablespace for it,
it uses the same tablespace as the template database it is copied from.
</para>
@ -468,7 +478,7 @@ SELECT spcname FROM pg_tablespace;
</para>
<para>
<productname>PostgreSQL</> makes extensive use of symbolic links
<productname>PostgreSQL</> makes use of symbolic links
to simplify the implementation of tablespaces. This
means that tablespaces can be used <emphasis>only</> on systems
that support symbolic links.

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.62 2007/04/06 22:33:41 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.63 2007/06/03 17:05:53 tgl Exp $
PostgreSQL documentation
-->
@ -240,9 +240,9 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] <replaceable class="parameter">name</re
<listitem>
<para>
The tablespace in which to create the index. If not specified,
<xref linkend="guc-default-tablespace"> is used, or the database's
default tablespace if <varname>default_tablespace</> is an empty
string.
<xref linkend="guc-default-tablespace"> is consulted, or
<xref linkend="guc-temp-tablespaces"> for indexes on temporary
tables.
</para>
</listitem>
</varlistentry>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.107 2007/02/01 00:28:18 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.108 2007/06/03 17:06:03 tgl Exp $
PostgreSQL documentation
-->
@ -645,9 +645,8 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
The <replaceable class="PARAMETER">tablespace</replaceable> is the name
of the tablespace in which the new table is to be created.
If not specified,
<xref linkend="guc-default-tablespace"> is used, or the database's
default tablespace if <varname>default_tablespace</> is an empty
string.
<xref linkend="guc-default-tablespace"> is consulted, or
<xref linkend="guc-temp-tablespaces"> if the table is temporary.
</para>
</listitem>
</varlistentry>
@ -660,9 +659,8 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
associated with a <literal>UNIQUE</literal> or <literal>PRIMARY
KEY</literal> constraint will be created.
If not specified,
<xref linkend="guc-default-tablespace"> is used, or the database's
default tablespace if <varname>default_tablespace</> is an empty
string.
<xref linkend="guc-default-tablespace"> is consulted, or
<xref linkend="guc-temp-tablespaces"> if the table is temporary.
</para>
</listitem>
</varlistentry>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.36 2006/09/18 19:54:01 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.37 2007/06/03 17:06:12 tgl Exp $
PostgreSQL documentation
-->
@ -184,9 +184,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name
The <replaceable class="PARAMETER">tablespace</replaceable> is the name
of the tablespace in which the new table is to be created.
If not specified,
<xref linkend="guc-default-tablespace"> is used, or the database's
default tablespace if <varname>default_tablespace</> is an empty
string.
<xref linkend="guc-default-tablespace"> is consulted, or
<xref linkend="guc-temp-tablespaces"> if the table is temporary.
</para>
</listitem>
</varlistentry>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_tablespace.sgml,v 1.6 2007/01/31 23:26:03 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_tablespace.sgml,v 1.7 2007/06/03 17:06:13 tgl Exp $
PostgreSQL documentation
-->
@ -36,7 +36,10 @@ DROP TABLESPACE [ IF EXISTS ] <replaceable class="PARAMETER">tablespacename</rep
The tablespace must be empty of all database objects before it can be
dropped. It is possible that objects in other databases might still reside
in the tablespace even if no objects in the current database are using
the tablespace.
the tablespace. Also, if the tablespace is listed in the <xref
linkend="guc-temp-tablespaces"> setting of any active session, the
<command>DROP</> might fail due to temporary files residing in the
tablespace.
</para>
</refsect1>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.65 2007/04/07 03:48:25 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.66 2007/06/03 17:06:13 tgl Exp $
PostgreSQL documentation
-->
@ -211,10 +211,10 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
have this privilege for the containing schema.
</para>
<para>
For tablespaces, allows tables and indexes to be created within the
tablespace, and allows databases to be created that have the tablespace
as their default tablespace. (Note that revoking this privilege
will not alter the placement of existing objects.)
For tablespaces, allows tables, indexes, and temporary files to be
created within the tablespace, and allows databases to be created that
have the tablespace as their default tablespace. (Note that revoking
this privilege will not alter the placement of existing objects.)
</para>
</listitem>
</varlistentry>

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/storage.sgml,v 1.17 2007/04/06 04:21:41 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/storage.sgml,v 1.18 2007/06/03 17:05:53 tgl Exp $ -->
<chapter id="storage">
@ -170,6 +170,17 @@ tablespace is not accessed through <filename>pg_tblspc</>, but corresponds to
<varname>PGDATA</><filename>/global</>.
</para>
<para>
Temporary files (for operations such as sorting more data than can fit in
memory) are created within <varname>PGDATA</><filename>/base/pgsql_tmp</>,
or within a <filename>pgsql_tmp</> subdirectory of a tablespace directory
if a tablespace other than <literal>pg_default</> is specified for them.
The name of a temporary file has the form
<filename>pgsql_tmp<replaceable>PPP</>.<replaceable>NNN</></filename>,
where <replaceable>PPP</> is the PID of the owning backend and
<replaceable>NNN</> distinguishes different files of that backend.
</para>
</sect1>
<sect1 id="storage-toast">