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

Commit4ca7b4d

Browse files
committed
More about chained mode and isolation.
1 parent962c66d commit4ca7b4d

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

‎src/man/begin.l

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/begin.l,v 1.5 1998/03/25 01:54:48 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/begin.l,v 1.6 1999/06/11 05:40:18 vadim Exp $
44
.TH BEGIN SQL 11/05/95 PostgreSQL PostgreSQL
55
.SH NAME
6-
begin - begins a transaction
6+
begin - begins a transaction in chained mode
77
.SH SYNOPSIS
88
.nf
99
\fBbegin\fP\fB[transaction|work]\fR
1010
.fi
1111
.SH DESCRIPTION
12-
This command begins a user transaction which Postgres will guarantee is
13-
serializable with respect to all concurrently executing transactions.
14-
Postgres uses two-phase locking to perform this task. If the transaction
15-
is committed, Postgres will ensure that all updates are done or none of
16-
them are done. Transactions have the standard ACID (atomic,
17-
consistent, isolatable, and durable) property.
12+
13+
By default, Postgres executes transactions in unchained mode (also known as
14+
autocommit feature in other DBMSes). In other words, each user statement is
15+
executed in its own transaction and commit is implicit (if execution was
16+
successfull). BEGIN initiates a user transaction in chained mode, i.e. all
17+
user statements after BEGIN command will be executed in single transaction
18+
untill explicit COMMIT, ROLLBACK or execution abort. Statements in chained
19+
mode are executed much faster, because of transaction start/commit requires
20+
significant CPU and disk activity. This mode is also required for
21+
consistency when changing one of related tables.
22+
23+
Default transaction isolation level in Postgres is READ COMMITTED one, when
24+
queries inside transaction see only changes committed before query
25+
execution. So, you have to use SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
26+
command just after BEGIN if you need in better transaction isolation. In
27+
SERIALIZABLE mode queries will see only changes committed before entire
28+
transaction began (actually, before execution of first DML statement in
29+
serializable transaction).
30+
31+
If the transaction is committed, Postgres will ensure either that all
32+
updates are done or else that none of them are done. Transactions have the
33+
standard ACID (atomic, consistent, isolatable, and durable) property.
34+
35+
\fBNote\fR: There is no explicit BEGIN command in SQL92; transaction
36+
initiation is always implicit and it terminates either with a COMMIT or with
37+
a ROLLBACK statement (i.e. all transactions are chained). SQL92 also
38+
requires SERIALIZABLE to be default transaction isolation level.
39+
1840
.SH "SEE ALSO"
1941
rollback(l),
20-
commit(l).
42+
commit(l),
43+
set(l),
44+
lock(l).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp