From fec3a8f5722b41a15327a4c0eb18f68ba07a51fd Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Sat, 31 Oct 2020 15:44:22 -0500
Subject: [PATCH 3/3] More fixes on top

---
 doc/src/sgml/architecture.sgml | 239 ++++++++++++++++-----------------
 1 file changed, 114 insertions(+), 125 deletions(-)

diff --git a/doc/src/sgml/architecture.sgml b/doc/src/sgml/architecture.sgml
index 6f819220dc..f3acdaa6b3 100644
--- a/doc/src/sgml/architecture.sgml
+++ b/doc/src/sgml/architecture.sgml
@@ -66,9 +66,7 @@
     When a client application tries to connect to a
     <glossterm linkend="glossary-database">database</glossterm>,
     this request is handled initially by the Postmaster. It
-    starts a new Backend process and instructs the client
-    application to connect to it. All further client requests
-    are handled by this process.
+    starts a new Backend process to service the client's requests.
    </para>
 
    <para>
@@ -89,7 +87,7 @@
     write actions take place. Modified pages are called dirty
     pages or dirty buffers and before they can be evicted they
     must be written to disk. This happens regularly by the
-    Background Writer and the Checkpointer process to ensure
+    Checkpointer and Background Writer processes to ensure
     that the disk version of the pages are up-to-date.
     The synchronisation from RAM to disk consists of two steps.
    </para>
@@ -117,7 +115,7 @@
    <para>
     Second, the transfer of dirty buffers from Shared Memory to
     files must take place. This is the primary task of the
-    Background Writer process. Because I/O activities can block
+    Checkpointer process. Because I/O activities can block
     other processes, it starts periodically and
     acts only for a short period. Doing so, its extensive (and
     expensive) I/O activities are spread over time, avoiding
@@ -136,7 +134,9 @@
     a possibly occurring recovery, which integrates the delta
     information of WAL into heap and index files, will happen
     by replaying only WAL past the last recorded checkpoint
-    on top of the current heap and files. This speeds up recovery.
+    on top of the current heap and files.
+    This limits the amount of WAL which needs to be replayed during recovery in
+    the event of a crash.
    </para>
 
    <para>
@@ -369,8 +369,8 @@
    <para>
     The subdirectory <literal>pg_wal</literal> contains the
     <glossterm linkend="glossary-wal-file">WAL files</glossterm>.
-    They arise and grow parallel to data changes in the
-    cluster and remain alive as long as
+    They arise and grow in parallel with data changes in the
+    cluster and remain as long as
     they are required for recovery, archiving, or replication.
    </para>
 
@@ -383,8 +383,8 @@
 
    <para>
     In <literal>pg_tblspc</literal>, there are symbolic links
-    that point to directories containing such SQL objects
-    that are created within tablespaces.
+    that point to directories containing SQL objects
+    that exist within a non-default tablespace.
    </para>
 
    <para>
@@ -459,7 +459,7 @@
     sequences. Every new transaction receives the next number as its ID.
     Therefore, this flow of xids represents the flow of transaction
     start events over time. But keep in mind that xids are independent of
-    any time measurement &mdash; in milliseconds or whatever. If you dive
+    any time measurement &mdash; in milliseconds or otherwise. If you dive
     deeper into <productname>PostgreSQL</productname>, you will recognize
     parameters with names such as 'xxx_age'. Despite their names,
     these '_age' parameters do not specify a period of time but represent
@@ -514,38 +514,36 @@
     executes an <command>UPDATE</command> of this row by
     changing the user data from <literal>'x'</literal> to
     <literal>'y'</literal>. According to the MVCC principles,
-    the data in the old version of the row does not change!
-    The value <literal>'x'</literal> remains as it was before.
-    Only <literal>xmax</literal> changes to <literal>135</literal>.
-    Now, this version is treated as valid exclusively for
+    the old version of the row is not changed!
+    Internally, an <command>UPDATE</command> command acts
+    as a <command>DELETE</command> command followed by
+    an <command>INSERT</command> command.
+    <literal>xmax</literal> of the old row version is changed to <literal>135</literal>,
+    and a new row version is added with
+    <literal>xmin</literal>=135,
+    <literal>xmax</literal>=0, and <literal>'y'</literal> in the
+    user data (plus any other user columns from the old version).
+    The old row version is visible only to
     transactions with xids from <literal>123</literal> to
-    <literal>134</literal>. As a substitute for the non-occurring
-    data change in the old version, the <command>UPDATE</command>
-    creates a new version of the row with its xid in
-    <literal>xmin</literal>, <literal>0</literal> in
-    <literal>xmax</literal>, and <literal>'y'</literal> in the
-    user data (plus all other user data from the old version).
-    This version is now valid for all future transactions.
+    <literal>134</literal>, and the new row version
+    is visible to all future transactions.
    </para>
 
    <para>
     All subsequent <command>UPDATE</command> commands behave
-    in the same way as the first one: they put their xid to
+    in the same way as the first one: they put their xid in
     <literal>xmax</literal> of the current version, create
-    the next version with their xid in <literal>xmin</literal>,
-    <literal>0</literal> in <literal>xmax</literal>, and the
-    new user data.
+    a new version with their xid in <literal>xmin</literal> and
+    <literal>0</literal> in <literal>xmax</literal>.
    </para>
 
    <para>
     Finally, a row may be deleted by a <command>DELETE</command>
     command. Even in this case, all versions of the row remain as
-    before. Nothing is thrown away so far! Only <literal>xmax</literal>
-    of the last version changes to the xid of the <command>DELETE</command>
-    transaction, which indicates that it is only valid for
-    transactions with xids older than its own (from
-    <literal>142</literal> to <literal>820</literal> in this
-    example).
+    before. Nothing is thrown away! Only <literal>xmax</literal>
+    of the last version is set to the xid of the <command>DELETE</command>
+    transaction, which indicates that (if committed) it is only visible to
+    transactions with xids older than that.
    </para>
 
    <para>
@@ -553,10 +551,10 @@
     of the same row in the table's heap file and leaves them there,
     even after a <command>DELETE</command> command. Only the youngest
     version is relevant for all future transactions. But the
-    system must also preserve some of the older ones for a
-    certain amount of time because the possibility exists that
-    they are or could become relevant for any pending
-    transactions. Over time, also the older ones get out of scope
+    system must also preserve some of the older ones for
+    awhile, because they could still be needed by
+    transactions which started before the deleting transaction commits.
+    Over time, also the older ones get out of scope
     for ALL transactions and therefore become unnecessary.
     Nevertheless, they do exist physically on the disk and occupy
    space.
@@ -571,26 +569,18 @@
      <simpara>
       <literal>xmin</literal> and <literal>xmax</literal>
       indicate the range from where to where
-      row versions are valid (visible) for transactions.
+      <firstterm>row versions</firstterm> are valid (visible) for transactions.
       This range doesn't imply any direct temporal meaning;
       the sequence of xids reflects only the sequence of
       transaction begin events. As
       xids grow, old row versions get out of scope over time.
-      If an old row version is no longer valid for ALL existing
-      transactions, it's called <firstterm>dead</firstterm>. The
-      space occupied by dead row versions is part of the
+      If an old row version is no longer relevant for ANY existing
+      transactions, it can be marked <firstterm>dead</firstterm>. The
+      space occupied by dead row versions is wasted space called
       <glossterm linkend="glossary-bloat">bloat</glossterm>.
      </simpara>
     </listitem>
 
-    <listitem>
-     <simpara>
-      Internally, an <command>UPDATE</command> command acts in the
-      same way as a <command>DELETE</command> command followed by
-      an <command>INSERT</command> command.
-     </simpara>
-    </listitem>
-
     <listitem>
      <simpara>
       Nothing gets wiped away &mdash; with the consequence that the database
@@ -610,12 +600,12 @@
 
    <para>
     As we have seen in the previous chapter, the database
-    tends to occupy more and more disk space, the
+    tends to occupy more and more disk space, caused by
     <glossterm linkend="glossary-bloat">bloat</glossterm>.
     This chapter explains how the SQL command
     <command>VACUUM</command> and the automatically running
     <firstterm>Autovacuum</firstterm> processes clean up
-    by eliminating bloat.
+    and avoid continued growth.
    </para>
 
    <note>
@@ -635,8 +625,8 @@
     special situations, or they start it in batch jobs which run
     periodically. Autovacuum processes run as part of the
     <link linkend="glossary-instance">Instance</link> at the server.
-    There is a constantly running Autovacuum daemon. It permanently
-    controls the state of all databases based on values that are collected by the
+    There is a constantly running Autovacuum daemon. It continuously
+    monitors the state of all databases based on values that are collected by the
     <link linkend="glossary-stats-collector">Statistics Collector</link>
     and starts Autovacuum processes whenever it detects
     certain situations. Thus, it's a dynamic behavior of
@@ -657,7 +647,7 @@
 
     <listitem>
      <simpara>
-      <firstterm>Freeze</firstterm>: Mark the youngest row version
+      <firstterm>Freeze</firstterm>: Mark old row version
       as frozen. This means that the version
       is always treated as valid (visible) independent from
       the <firstterm>wraparound problem</firstterm> (see below).
@@ -684,22 +674,22 @@
    </itemizedlist>
 
    <para>
-    The eagerness &mdash; you can call it 'aggression' &mdash; of the
+    The eagerness &mdash; you can call it 'aggressiveness' &mdash; of the
     operations for <emphasis>eliminating bloat</emphasis> and
     <emphasis>freeze</emphasis> is controlled by configuration
     parameters, runtime flags, and in extreme situations by
     the processes themselves. Because vacuum operations typically are I/O
     intensive, which can hinder other activities, Autovacuum
     avoids performing many vacuum operations in bulk. Instead,
-    it carries out many small actions with time gaps in between.
-    The SQL command <command>VACUUM</command> runs immediately
-    and without any time gaps.
+    it carries out many small actions with delay points in between.
+    When invoked manually, the SQL command <command>VACUUM</command>
+    runs immediately and (by default) without any time delay.
    </para>
 
    <bridgehead renderas="sect2">Eliminate Bloat</bridgehead>
 
    <para>
-    To determine which of the row versions are superfluous, the
+    To determine which of the row versions are no longer needed, the
     elimination operation must evaluate <literal>xmax</literal>
     against several criteria which all must apply:
    </para>
@@ -740,14 +730,13 @@
    </itemizedlist>
 
    <para>
-    After the vacuum operation detects a superfluous row version, it
+    After the vacuum operation detects an unused row version, it
     marks its space as free for future use of writing actions. Only
     in rare situations (or in the case of <command>VACUUM FULL</command>),
-    this space is released to the operating system. In most cases,
+    is this space released to the operating system. In most cases,
     it remains occupied by <productname>PostgreSQL</productname>
     and will be used by future <command>INSERT</command> or
-    <command>UPDATE</command> commands concerning this row or a
-    completely different one.
+    <command>UPDATE</command> commands to this table.
    </para>
 
    <para>
@@ -761,9 +750,9 @@
        in its default format, i.e., without any option. To boost performance,
        in this and the next case <command>VACUUM</command> does not
        read and act on all pages of the heap.
-       The Visibility Map, which is very compact and therefore has a small
-       size, contains information about pages, where bloat-candidates might
-       be found. Only such pages are processed.
+       The Visibility Map, which is very compact and therefore fast to read,
+       contains information about which pages have no deleted row versions, and
+       can be skipped by vacuum.
       </simpara>
      </listitem>
 
@@ -771,7 +760,7 @@
       <simpara>
        When a client issues the SQL command <command>VACUUM</command>
        with the option <command>FREEZE</command>. (In this case,
-       it undertakes much more actions, see
+       it undertakes many more actions, see
        <link linkend="tutorial-freeze">Freeze Row Versions</link>.)
       </simpara>
      </listitem>
@@ -780,12 +769,11 @@
       <simpara>
        When a client issues the SQL command <command>VACUUM</command>
        with the option <command>FULL</command>.
-       Also, in this mode, the bloat disappears, but the strategy used
-       is very different: in this case, the complete table is copied
-       to a different file skipping all outdated row versions. This
-       leads to a significant reduction of used disk space because
-       the new file contains only the actual data. The old file
-       is deleted.
+       In this mode, an exclusive lock is taken, and
+       the whole table is copied to a different file, skipping all outdated row
+       versions.  All bloat is thereby eliminated, which
+       may lead to a significant reduction of used disk space.
+       The old file is deleted.
       </simpara>
      </listitem>
 
@@ -807,17 +795,17 @@
    <para>
     This logic only applies to row versions of the heap. Index entries
     don't use <literal>xmin/xmax</literal>. Nevertheless, such index
-    entries, which would lead to outdated row versions, are released
+    entries, which would lead to outdated row versions, are cleaned up
     accordingly.
    </para>
 
    <para>
     The above descriptions omit the fact that xids on a real computer
-    have a limited size. They count up in the same way as sequences, and after
-    a certain number of new transactions they are forced to restart
+    have a limited size, and after
+    a certain number of transactions they are forced to restart
     from the beginning, which is called <firstterm>wraparound</firstterm>.
     Therefore the terms 'old transaction' / 'young transaction' does
-    not always correlate with low / high values of xids. Near to the
+    not always correlate with low / high values of xids. Near the
     wraparound point, there are cases where <literal>xmin</literal> has
     a higher value than <literal>xmax</literal>, although their meaning
     is said to be older than <literal>xmax</literal>.
@@ -856,7 +844,7 @@
     and the corresponding transactions of <literal>xmin</literal>
     and <literal>xmax</literal> must be committed. However,
     <productname>PostgreSQL</productname> has to consider the
-    possibility of wraparounds.
+    possibility of wraparound.
     Therefore the decision becomes more complex. The general
     idea of the solution is to use the 'between
     <literal>xmin</literal> and <literal>xmax</literal>'
@@ -883,7 +871,7 @@
     <listitem>
      <simpara>
       With each newly created transaction the two split-points
-      move forward. When 'txid_current + 2^31' would reach a
+      move forward. If 'txid_current + 2^31' reached a
       row version with <literal>xmin</literal> equal to that value, it would
       immediately jump from 'past' to 'future' and would be
       no longer visible!
@@ -892,11 +880,11 @@
 
     <listitem>
      <simpara>
-      To avoid this unacceptable extinction of data, the vacuum
-      operation <firstterm>freeze</firstterm> clears the situation
-      long before the split-point is reached. It sets a flag
-      in the header of the row version, which completely eliminates
-      the future use of <literal>xmin/xmax</literal> and indicates
+      If not handled in some way, data inserted many transactions ago would become invisibile.
+      The vacuum operation <firstterm>freeze</firstterm> avoids this
+      long before the split-point is reached by setting a flag
+      in the header of the row version which avoids
+      future comparison of its <literal>xmin/xmax</literal> and indicates
       that the version is valid not only in the 'past'-half
       but also in the 'future'-half as well as in all coming
       <glossterm linkend="glossary-xid">epochs</glossterm>.
@@ -943,19 +931,19 @@
        When a client issues the SQL command <command>VACUUM</command>
        with its <command>FREEZE</command> option. In this case, all
        pages are processed that are marked in the Visibility Map
-       to potentially have unfrozen rows.
+       as potentially having unfrozen rows.
       </simpara>
      </listitem>
      <listitem>
       <simpara>
        When a client issues the SQL command <command>VACUUM</command> without
-       any options but finds that there are xids older than
+       any options but there are xids older than
        <xref linkend="guc-vacuum-freeze-table-age"/>
        (default: 150 million) minus
        <xref linkend="guc-vacuum-freeze-min-age"/>
        (default: 50 million).
        As before, all pages are processed that are
-       marked in the Visibility Map to potentially have unfrozen
+       marked in the Visibility Map as potentially having unfrozen
        rows.
       </simpara>
      </listitem>
@@ -981,7 +969,7 @@
         <simpara>
          The process switches
          to an <emphasis>aggressive mode</emphasis> if it recognizes
-         that for the processed table their oldest xid exceeds
+         that for the processed table the oldest xid exceeds
          <xref linkend="guc-autovacuum-freeze-max-age"/>
          (default: 200 million). The value of the oldest unfrozen
          xid is stored per table in <literal>pg_class.relfrozenxid</literal>.
@@ -1037,22 +1025,21 @@
    <para>
     The <link linkend="glossary-vm">Visibility Map</link>
     (VM) contains two flags &mdash; stored as
-    two bits &mdash; for each page of the heap. If the first bit
-    is set, that indicates that the associated page does not
-    contain any bloat. If the second one is set, that indicates
-    that the page contains only frozen rows.
+    two bits &mdash; for each page of the heap. The first bit
+    indicates that the associated page does not
+    contain any bloat. The second bit indicates
+    that the page contains only frozen row versions.
    </para>
 
    <para>
      Please consider two details. First, in most cases a page
-     contains many rows, some of them in many versions.
+     contains many rows or row-versions.
      However, the flags are associated with the page,
-     not with a row or a row version. The flags are set
+     not with an individual row version. The flags are set
      only under the condition that they are valid for ALL
      row versions of the page. Second, since there
      are only two bits per page, the VM is considerably
-     smaller than the heap. Therefore it is buffered
-     in RAM in almost all cases.
+     smaller than the heap.
    </para>
 
    <para>
@@ -1068,7 +1055,7 @@
     The <link linkend="glossary-fsm">Free Space Map</link>
     (FSM) tracks the amount of free space per page. It is
     organized as a highly condensed b-tree of (rounded) sizes.
-    As long as <command>VACUUM</command> or Autovacuum change
+    Whenever <command>VACUUM</command> or Autovacuum changes
     the free space on any processed page, they log the new
     values in the FSM in the same way as all other writing
     processes.
@@ -1077,18 +1064,19 @@
    <bridgehead renderas="sect2">Statistics</bridgehead>
 
    <para>
-    Statistic information helps the <link
+    Statistical information helps the <link
     linkend="planner-stats">Query Planner</link> to make optimal
     decisions for the generation of execution plans. This
     information can be gathered with the SQL commands
     <command>ANALYZE</command> or <command>VACUUM ANALYZE</command>.
-    But also Autovacuum processes gather
+    But Autovacuum processes also gather
     such information. Depending on the percentage of changed rows
-    per table <xref linkend="guc-autovacuum-analyze-scale-factor"/>,
+    <xref linkend="guc-autovacuum-analyze-scale-factor"/>,
+    and minimum number of changed rows <xref linkend="guc-autovacuum-analyze-threshold"/>,
     the Autovacuum daemon starts Autovacuum processes to collect
-    statistics per table. This dynamic invocation of analyze
-    operations allows <productname>PostgreSQL</productname> to
-    adopt queries to changing circumstances.
+    statistics per table. The automatic analysis
+    allows <productname>PostgreSQL</productname> to
+    adapt query execution to changing circumstances.
    </para>
 
    <para>
@@ -1149,7 +1137,7 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
 
    <para>
     The atomicity also affects the visibility of changes. No
-    connection running simultaneously to a data modifying
+    connection running simultaneously with a data modifying
     transaction will ever see any change before the
     transaction successfully executes a <command>COMMIT</command>
     &mdash; even in the lowest
@@ -1228,9 +1216,9 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
 
    <para>
     Transactions ensure that the
-    <glossterm linkend="glossary-consistency">consistency</glossterm>
-    of the complete database always remains valid. Declarative
-    rules like
+    database always remains
+    <glossterm linkend="glossary-consistency">consistent</glossterm>.
+    Declarative rules like
     <link linkend="ddl-constraints-primary-keys">primary</link>- or
     <link linkend="ddl-constraints-fk">foreign keys</link>,
     <link linkend="ddl-constraints-check-constraints">checks</link>,
@@ -1248,11 +1236,12 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
    </para>
 
    <para>
-    Lastly, it is worth to notice that changes done by a
-    committed transaction will survive all future application,
-    instance, or hardware failures. The next chapter
-    explains this
-    <glossterm linkend="glossary-durability">durability</glossterm>.
+    Lastly, it is worth noticing that changes done by a
+    committed transaction will survive all failures in the application or
+    database cluster.
+    The next chapter explains the
+    <glossterm linkend="glossary-durability">durability</glossterm>
+    guarantees.
    </para>
   </sect1>
 
@@ -1309,7 +1298,7 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     which include the new data values and information about commit
     actions. The WAL records are written first. Second,
     the data itself shall exist in the heap and index files.
-    In opposite to the WAL records, this part may or may
+    In constrast with the WAL records, this part may or may
     not have been transferred entirely from Shared Memory
     to the files.
    </para>
@@ -1321,15 +1310,15 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     a consistent state, especially that all WAL records up to
     this point were successfully stored in heap and index files. Starting
     here, the recovery process copies the remaining WAL records
-    to heap and index. As a result, the files contain all
-    changes and reach a consistent state. Changes of committed
-    transactions are visible; those of uncommited transactions
+    to heap and index. As a result, the heap files contain all
+    changes recorded to the WAL and reach a consistent state. Changes of committed
+    transactions are visible; those of uncommitted transactions
     are also in the files, but - as usual - they are never seen
-    by any of the following transactions because uncommited
+    by any of the following transactions because uncommitted
     changes are never shown. Such recovery actions run
     completely automatically, it is not necessary that a
     database administrator configure or start anything by
-    himself.
+    themself.
    </para>
 
    <bridgehead renderas="sect3">Disk crash</bridgehead>
@@ -1341,7 +1330,7 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     prepare for such a situation.
    </para>
    <para>
-    He obviously needs a backup. How to take such a backup
+    They obviously needs a backup. How to take such a backup
     and use it as a starting point for a recovery of the
     cluster is explained in more detail in the next
     <link linkend="tutorial-backup">chapter</link>.
@@ -1353,11 +1342,11 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     and there is no room for additional data. In this case,
     <productname>PostgreSQL</productname> stops accepting
     data-modifying commands or even terminates completely.
-    No data loss or data corruption will occur.
+    Committed data is neither lost nor corrupted.
    </para>
    <para>
-    To come out of such a situation, the administrator should
-    remove unused files from this disk. But he should never
+    To recover from such a situation, the administrator should
+    remove unused files from this disk. But they should never
     delete files from the
     <glossterm linkend="glossary-data-directory">data directory</glossterm>.
     Nearly all of them are necessary for the consistency
@@ -1428,9 +1417,9 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     The tool <command>pg_dump</command> is able to take a
     <link linkend="backup-dump">copy</link>
     of the complete cluster or certain parts of it. It stores
-    the copy in the form of SQL <command>CREATE</command> and
-    <command>INSERT</command> commands. It runs in
-    parallel to other processes in its own transaction.
+    the copy in the form of SQL commands like <command>CREATE</command> and
+    <command>COPY</command>. It runs in
+    parallel with other processes in its own transaction.
    </para>
    <para>
     The output of <command>pg_dump</command> may be used as
@@ -1457,7 +1446,7 @@ UPDATE accounts SET balance = balance + 100.00 WHERE name = 'Bob';
     directory structure plus files which contain a
     consistent copy of the original cluster.
     <command>pg_basebackup</command> runs in
-    parallel to other processes in its own transaction.
+    parallel with other processes in its own transaction.
    </para>
    <para>
     The second step is recommended but not necessary. All
-- 
2.17.0

