diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-12-29 06:48:53 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-12-29 06:48:53 -0500 |
commit | 53dbc27c62d8e1b6c5253feba04a5094cb8fe046 (patch) | |
tree | b27563b69fa73dc4b7dc873bfc653bedc6ba1e05 /doc/src | |
parent | 9b8aff8c192e2f313f90395d114c58a9ef84f97f (diff) | |
download | postgresql-53dbc27c62d8e1b6c5253feba04a5094cb8fe046.tar.gz postgresql-53dbc27c62d8e1b6c5253feba04a5094cb8fe046.zip |
Support unlogged tables.
The contents of an unlogged table are WAL-logged; thus, they are not
available on standby servers and are truncated whenever the database
system enters recovery. Indexes on unlogged tables are also unlogged.
Unlogged GiST indexes are not currently supported.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 3 | ||||
-rw-r--r-- | doc/src/sgml/indexam.sgml | 11 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_table.sgml | 21 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_table_as.sgml | 12 | ||||
-rw-r--r-- | doc/src/sgml/ref/pg_dump.sgml | 11 | ||||
-rw-r--r-- | doc/src/sgml/ref/pg_dumpall.sgml | 11 | ||||
-rw-r--r-- | doc/src/sgml/storage.sgml | 22 |
7 files changed, 86 insertions, 5 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 9fa20cfeee9..0eeb499207e 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1644,7 +1644,8 @@ <entry><type>bool</type></entry> <entry></entry> <entry> - <literal>p</> = permanent table, <literal>t</> = temporary table + <literal>p</> = permanent table, <literal>u</> = unlogged table, + <literal>t</> = temporary table </entry> </row> diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index c4eb59f7be7..51e70e92006 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -167,6 +167,17 @@ ambuild (Relation heapRelation, <para> <programlisting> +void +ambuildempty (Relation indexRelation); +</programlisting> + Build an empty index, and write it to the initialization fork (INIT_FORKNUM) + of the given relation. This method is called only for unlogged tables; the + empty index written to the initialization fork will be copied over the main + relation fork on each server restart. + </para> + + <para> +<programlisting> bool aminsert (Relation indexRelation, Datum *values, diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index bc5dff03296..efb4b1aca18 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -21,7 +21,7 @@ PostgreSQL documentation <refsynopsisdiv> <synopsis> -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name</replaceable> ( [ +CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name</replaceable> ( [ { <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">data_type</replaceable> [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ] | <replaceable>table_constraint</replaceable> | LIKE <replaceable>parent_table</replaceable> [ <replaceable>like_option</replaceable> ... ] } @@ -32,7 +32,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] <repl [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] [ TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ] -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name</replaceable> +CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name</replaceable> OF <replaceable class="PARAMETER">type_name</replaceable> [ ( { <replaceable class="PARAMETER">column_name</replaceable> WITH OPTIONS [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ] | <replaceable>table_constraint</replaceable> } @@ -165,6 +165,23 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] <repl </varlistentry> <varlistentry> + <term><literal>UNLOGGED</></term> + <listitem> + <para> + If specified, the table is created as an unlogged table. Data written + to unlogged tables is not written to the write-ahead log (see <xref + linkend="wal">), which makes them considerably faster than ordinary + tables. However, they are not crash-safe: an unlogged table is + automatically truncated after a crash or unclean shutdown. The contents + of an unlogged table are also not replicated to standby servers. + Any indexes created on an unlogged table are automatically unlogged as + well; however, unlogged <link linkend="GiST">GiST indexes</link> are + currently not supported and cannot be created on an unlogged table. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><literal>IF NOT EXISTS</></term> <listitem> <para> diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml index 3a256d1aaed..ff71078d1e2 100644 --- a/doc/src/sgml/ref/create_table_as.sgml +++ b/doc/src/sgml/ref/create_table_as.sgml @@ -21,7 +21,7 @@ PostgreSQL documentation <refsynopsisdiv> <synopsis> -CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> +CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ] [ WITH ( <replaceable class="PARAMETER">storage_parameter</replaceable> [= <replaceable class="PARAMETER">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ] @@ -82,6 +82,16 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name </varlistentry> <varlistentry> + <term><literal>UNLOGGED</></term> + <listitem> + <para> + If specified, the table is created as an unlogged table. + Refer to <xref linkend="sql-createtable"> for details. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><replaceable>table_name</replaceable></term> <listitem> <para> diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index fd13c0d9e75..b291a257ea7 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -670,6 +670,17 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>--no-unlogged-table-data</option></term> + <listitem> + <para> + Do not dump the contents of unlogged tables. This option has no + effect on whether or not the table definitions (schema) are dumped; + it only suppresses dumping the table data. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>--quote-all-identifiers</></term> <listitem> <para> diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index 39da0b29490..04e95e876d1 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -202,6 +202,17 @@ PostgreSQL documentation </varlistentry> <varlistentry> + <term><option>--no-unlogged-table-data</option></term> + <listitem> + <para> + Do not dump the contents of unlogged tables. This option has no + effect on whether or not the table definitions (schema) are dumped; + it only suppresses dumping the table data. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>-r</option></term> <term><option>--roles-only</option></term> <listitem> diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml index cda7f6452f5..430df4a8438 100644 --- a/doc/src/sgml/storage.sgml +++ b/doc/src/sgml/storage.sgml @@ -147,7 +147,9 @@ the relation. The free space map is stored in a file named with the filenode number plus the suffix <literal>_fsm</>. Tables also have a <firstterm>visibility map</>, stored in a fork with the suffix <literal>_vm</>, to track which pages are known to have no dead tuples. The visibility map is -described further in <xref linkend="storage-vm">. +described further in <xref linkend="storage-vm">. Unlogged tables and indexes +have a third fork, known as the initialization fork, which is stored in a fork +with the suffix <literal>_init</literal> (see <xref linkend="storage-init">). </para> <caution> @@ -485,6 +487,24 @@ a bit is not set, it might or might not be true. </sect1> +<sect1 id="storage-init"> + +<title>The Initialization Fork</title> + +<indexterm> + <primary>Initialization Fork</primary> +</indexterm> + +<para> +Each unlogged table, and each index on an unlogged table, has an initialization +fork. The initialization fork is an empty table or index of the appropriate +type. When an unlogged table must be reset to empty due to a crash, the +initialization fork is copied over the main fork, and any other forks are +erased (they will be recreated automatically as needed). +</para> + +</sect1> + <sect1 id="storage-page-layout"> <title>Database Page Layout</title> |