|
1 | 1 | .\" This is -*-nroff-*-
|
2 | 2 | .\" 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 $ |
4 | 4 | .TH BEGIN SQL 11/05/95 PostgreSQL PostgreSQL
|
5 | 5 | .SH NAME
|
6 |
| -begin - begins a transaction |
| 6 | +begin - begins a transaction in chained mode |
7 | 7 | .SH SYNOPSIS
|
8 | 8 | .nf
|
9 | 9 | \fBbegin\fP \fB[transaction|work]\fR
|
10 | 10 | .fi
|
11 | 11 | .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 | + |
18 | 40 | .SH "SEE ALSO"
|
19 | 41 | rollback(l),
|
20 |
| -commit(l). |
| 42 | +commit(l), |
| 43 | +set(l), |
| 44 | +lock(l). |
0 commit comments