From 53dbc27c62d8e1b6c5253feba04a5094cb8fe046 Mon Sep 17 00:00:00 2001
From: Robert Haas
Date: Wed, 29 Dec 2010 06:48:53 -0500
Subject: 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.
---
doc/src/sgml/catalogs.sgml | 3 ++-
doc/src/sgml/indexam.sgml | 11 +++++++++++
doc/src/sgml/ref/create_table.sgml | 21 +++++++++++++++++++--
doc/src/sgml/ref/create_table_as.sgml | 12 +++++++++++-
doc/src/sgml/ref/pg_dump.sgml | 11 +++++++++++
doc/src/sgml/ref/pg_dumpall.sgml | 11 +++++++++++
doc/src/sgml/storage.sgml | 22 +++++++++++++++++++++-
7 files changed, 86 insertions(+), 5 deletions(-)
(limited to 'doc')
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 @@
bool
- p> = permanent table, t> = temporary table
+ p> = permanent table, u> = unlogged table,
+ t> = temporary table
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,
+void
+ambuildempty (Relation indexRelation);
+
+ 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.
+
+
+
+
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
-CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] table_name ( [
+CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name ( [
{ column_namedata_type [ column_constraint [ ... ] ]
| table_constraint
| LIKE parent_table [ like_option ... ] }
@@ -32,7 +32,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] tablespace ]
-CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ] table_name
+CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name
OF type_name [ (
{ column_name WITH OPTIONS [ column_constraint [ ... ] ]
| table_constraint }
@@ -164,6 +164,23 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE [ IF NOT EXISTS ]
+
+ UNLOGGED>
+
+
+ If specified, the table is created as an unlogged table. Data written
+ to unlogged tables is not written to the write-ahead log (see ), 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 GiST indexes are
+ currently not supported and cannot be created on an unlogged table.
+
+
+
+
IF NOT EXISTS>
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
-CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name
+CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE table_name
[ (column_name [, ...] ) ]
[ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
@@ -81,6 +81,16 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name
+
+ UNLOGGED>
+
+
+ If specified, the table is created as an unlogged table.
+ Refer to for details.
+
+
+
+
table_name
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
@@ -669,6 +669,17 @@ PostgreSQL documentation
+
+
+
+
+ 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.
+
+
+
+
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
@@ -201,6 +201,17 @@ PostgreSQL documentation
+
+
+
+
+ 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.
+
+
+
+
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 _fsm>. Tables also have a
visibility map>, stored in a fork with the suffix _vm>,
to track which pages are known to have no dead tuples. The visibility map is
-described further in .
+described further in . Unlogged tables and indexes
+have a third fork, known as the initialization fork, which is stored in a fork
+with the suffix _init (see ).
@@ -485,6 +487,24 @@ a bit is not set, it might or might not be true.
+
+
+The Initialization Fork
+
+
+ Initialization Fork
+
+
+
+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).
+
+
+
+
Database Page Layout
--
cgit v1.2.3