Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7e2de6

Browse files
committed
Add note that TRUNCATE is not MVCC-safe.
1 parentb0194ab commitd7e2de6

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

‎doc/src/sgml/ref/truncate.sgml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.22 2007/01/31 23:26:04 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/truncate.sgml,v 1.23 2007/04/07 17:12:15 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -31,7 +31,9 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C
3131
<command>TRUNCATE</command> quickly removes all rows from a set of
3232
tables. It has the same effect as an unqualified
3333
<command>DELETE</command> on each table, but since it does not actually
34-
scan the tables it is faster. This is most useful on large tables.
34+
scan the tables it is faster; furthermore it reclaims disk space
35+
immediately, rather than requiring a subsequent vacuum operation.
36+
This is most useful on large tables.
3537
</para>
3638
</refsect1>
3739

@@ -92,6 +94,27 @@ TRUNCATE [ TABLE ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ C
9294
<command>TRUNCATE</> will not run any user-defined <literal>ON
9395
DELETE</literal> triggers that might exist for the tables.
9496
</para>
97+
98+
<para>
99+
<command>TRUNCATE</> is not MVCC-safe (see <xref linkend="mvcc">
100+
for general information about MVCC). After truncation, the table
101+
will appear empty to all concurrent transactions, even if they are
102+
using a snapshot taken before the truncation occurred. This will
103+
only be an issue for a transaction that did not touch the table
104+
before the truncation started &mdash; any transaction that has done
105+
so would hold at least <literal>ACCESS SHARE</literal> lock,
106+
which would block
107+
<command>TRUNCATE</> until that transaction completes. So
108+
truncation will not cause any apparent inconsistency in the table
109+
contents for successive queries on the same table, but it could
110+
cause visible inconsistency between the contents of the
111+
truncated table and other tables.
112+
</para>
113+
114+
<para>
115+
<command>TRUNCATE</> is transaction-safe, however: the truncation
116+
will roll back if the surrounding transaction does not commit.
117+
</para>
95118
</refsect1>
96119

97120
<refsect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp