File: wal-intro.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (54 lines) | stat: -rw-r--r-- 3,532 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>26.2.Write-Ahead Logging (WAL)</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="wal.html" title="Chapter26.Reliability and the Write-Ahead Log">
<link rel="prev" href="wal.html" title="Chapter26.Reliability and the Write-Ahead Log">
<link rel="next" href="wal-configuration.html" title="26.3.WAL Configuration">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="wal-intro"></a>26.2.Write-Ahead Logging (<acronym class="acronym">WAL</acronym>)</h2></div></div></div>
<a name="id673650"></a><a name="id673659"></a><p>    <em class="firstterm">Write-Ahead Logging</em> (<acronym class="acronym">WAL</acronym>)
    is a standard approach to transaction logging.  Its detailed
    description may be found in most (if not all) books about
    transaction processing. Briefly, <acronym class="acronym">WAL</acronym>'s central
    concept is that changes to data files (where tables and indexes
    reside) must be written only after those changes have been logged,
    that is, when log records describing the changes have been flushed
    to permanent storage. If we follow this procedure, we do not need
    to flush data pages to disk on every transaction commit, because we
    know that in the event of a crash we will be able to recover the
    database using the log: any changes that have not been applied to
    the data pages can be redone from the log records.  (This is
    roll-forward recovery, also known as REDO.)
   </p>
<p>    A major benefit of using <acronym class="acronym">WAL</acronym> is a
    significantly reduced number of disk writes, because only the log
    file needs to be flushed to disk at the time of transaction
    commit, rather than every data file changed by the transaction.
    In multiuser environments, commits of many transactions
    may be accomplished with a single <code class="function">fsync</code> of
    the log file. Furthermore, the log file is written sequentially,
    and so the cost of syncing the log is much less than the cost of
    flushing the data pages.   This is especially true for servers
    handling many small transactions touching different parts of the data
    store.
   </p>
<p>    <acronym class="acronym">WAL</acronym> also makes it possible to support on-line
    backup and point-in-time recovery, as described in <a href="backup-online.html" title="23.3.On-line backup and point-in-time recovery (PITR)">Section23.3, &#8220;On-line backup and point-in-time recovery (PITR)&#8221;</a>.  By archiving the WAL data we can support
    reverting to any time instant covered by the available WAL data:
    we simply install a prior physical backup of the database, and
    replay the WAL log just as far as the desired time.  What's more,
    the physical backup doesn't have to be an instantaneous snapshot
    of the database state [mdash ] if it is made over some period of time,
    then replaying the WAL log for that period will fix any internal
    inconsistencies.
   </p>
</div></body>
</html>