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

Commitf507895

Browse files
committed
doc: add section about heap-only tuples (HOT)
Reported-by: Jonathan S. KatzDiscussion:https://postgr.es/m/c59ffbd5-96ac-a5a5-a401-14f627ca1405@postgresql.orgBackpatch-through: 11
1 parentc0252d7 commitf507895

File tree

8 files changed

+86
-10
lines changed

8 files changed

+86
-10
lines changed

‎doc/src/sgml/acronyms.sgml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,7 @@
299299
<term><acronym>HOT</acronym></term>
300300
<listitem>
301301
<para>
302-
<ulink
303-
url="https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/access/heap/README.HOT;hb=HEAD">Heap-Only
304-
Tuples</ulink>
302+
<link linkend="storage-hot">Heap-Only Tuples</link>
305303
</para>
306304
</listitem>
307305
</varlistentry>

‎doc/src/sgml/catalogs.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3841,7 +3841,8 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
38413841
<entry>
38423842
If true, queries must not use the index until the <structfield>xmin</structfield>
38433843
of this <structname>pg_index</structname> row is below their <symbol>TransactionXmin</symbol>
3844-
event horizon, because the table may contain broken HOT chains with
3844+
event horizon, because the table may contain broken <link
3845+
linkend="storage-hot">HOT chains</link> with
38453846
incompatible rows that they can see
38463847
</entry>
38473848
</row>

‎doc/src/sgml/config.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4057,7 +4057,8 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
40574057
<listitem>
40584058
<para>
40594059
Specifies the number of transactions by which <command>VACUUM</command> and
4060-
<acronym>HOT</acronym> updates will defer cleanup of dead row versions. The
4060+
<link linkend="storage-hot"><acronym>HOT</acronym> updates</link>
4061+
will defer cleanup of dead row versions. The
40614062
default is zero transactions, meaning that dead row versions can be
40624063
removed as soon as possible, that is, as soon as they are no longer
40634064
visible to any open transaction. You may wish to set this to a

‎doc/src/sgml/indexam.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
extant versions of the same logical row; to an index, each tuple is
4646
an independent object that needs its own index entry. Thus, an
4747
update of a row always creates all-new index entries for the row, even if
48-
the key values did not change. (HOT tuples are an exception to this
48+
the key values did not change. (<link linkend="storage-hot">HOT
49+
tuples</link> are an exception to this
4950
statement; but indexes do not deal with those, either.) Index entries for
5051
dead tuples are reclaimed (by vacuuming) when the dead tuples themselves
5152
are reclaimed.

‎doc/src/sgml/indices.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ CREATE INDEX test1_id_index ON test1 (id);
104104

105105
<para>
106106
After an index is created, the system has to keep it synchronized with the
107-
table. This adds overhead to data manipulation operations.
107+
table. This adds overhead to data manipulation operations. Indexes can
108+
also prevent the creation of <link linkend="storage-hot">heap-only
109+
tuples</link>.
108110
Therefore indexes that are seldom or never used in queries
109111
should be removed.
110112
</para>
@@ -734,7 +736,7 @@ CREATE INDEX people_names ON people ((first_name || ' ' || last_name));
734736
<para>
735737
Index expressions are relatively expensive to maintain, because the
736738
derived expression(s) must be computed for each row insertion
737-
and non-HOT update. However, the index expressions are
739+
and<link linkend="storage-hot">non-HOT update.</link> However, the index expressions are
738740
<emphasis>not</emphasis> recomputed during an indexed search, since they are
739741
already stored in the index. In both examples above, the system
740742
sees the query as just <literal>WHERE indexedcolumn = 'constant'</literal>

‎doc/src/sgml/monitoring.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2789,7 +2789,8 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
27892789
<row>
27902790
<entry><structfield>n_tup_upd</structfield></entry>
27912791
<entry><type>bigint</type></entry>
2792-
<entry>Number of rows updated (includes HOT updated rows)</entry>
2792+
<entry>Number of rows updated (includes <link
2793+
linkend="storage-hot">HOT updated rows</link> updated rows)</entry>
27932794
</row>
27942795
<row>
27952796
<entry><structfield>n_tup_del</structfield></entry>

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,9 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
13471347
to the indicated percentage; the remaining space on each page is
13481348
reserved for updating rows on that page. This gives <command>UPDATE</command>
13491349
a chance to place the updated copy of a row on the same page as the
1350-
original, which is more efficient than placing it on a different page.
1350+
original, which is more efficient than placing it on a different
1351+
page, and makes <link linkend="storage-hot">heap-only tuple
1352+
updates</link> more likely.
13511353
For a table whose entries are never updated, complete packing is the
13521354
best choice, but in heavily updated tables smaller fillfactors are
13531355
appropriate. This parameter cannot be set for TOAST tables.

‎doc/src/sgml/storage.sgml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,4 +1070,74 @@ data. Empty in ordinary tables.</entry>
10701070
</sect2>
10711071
</sect1>
10721072

1073+
<sect1 id="storage-hot">
1074+
1075+
<title>Heap-Only Tuples (<acronym>HOT</acronym>)</title>
1076+
1077+
<para>
1078+
To allow for high concurrency, <productname>PostgreSQL</productname>
1079+
uses <link linkend="mvcc-intro">multiversion concurrency
1080+
control</link> (<acronym>MVCC</acronym>) to store rows. However,
1081+
<acronym>MVCC</acronym> has some downsides for update queries.
1082+
Specifically, updates require new versions of rows to be added to
1083+
tables. This can also require new index entries for each updated row,
1084+
and removal of old versions of rows and their index entries can be
1085+
expensive.
1086+
</para>
1087+
1088+
<para>
1089+
To help reduce the overhead of updates,
1090+
<productname>PostgreSQL</productname> has an optimization called
1091+
heap-only tuples (<acronym>HOT</acronym>). This optimization is
1092+
possible when:
1093+
1094+
<itemizedlist>
1095+
<listitem>
1096+
<para>
1097+
The update does not modify any columns referenced by the table's
1098+
indexes, including expression and partial indexes.
1099+
</para>
1100+
</listitem>
1101+
<listitem>
1102+
<para>
1103+
There is sufficient free space on the page containing the old row
1104+
for the updated row.
1105+
</para>
1106+
</listitem>
1107+
</itemizedlist>
1108+
1109+
In such cases, heap-only tuples provide two optimizations:
1110+
1111+
<itemizedlist>
1112+
<listitem>
1113+
<para>
1114+
New index entries are not needed to represent updated rows.
1115+
</para>
1116+
</listitem>
1117+
<listitem>
1118+
<para>
1119+
Old versions of updated rows can be completely removed during normal
1120+
operation, including <command>SELECT</command>s, instead of requiring
1121+
periodic vacuum operations. (This is possible because indexes
1122+
do not reference their <link linkend="storage-page-layout">page
1123+
item identifiers</link>.)
1124+
</para>
1125+
</listitem>
1126+
</itemizedlist>
1127+
</para>
1128+
1129+
<para>
1130+
In summary, heap-only tuple updates can only be created
1131+
if columns used by indexes are not updated. You can
1132+
increase the likelihood of sufficient page space for
1133+
<acronym>HOT</acronym> updates by decreasing a table's <link
1134+
linkend="sql-createtable"><literal>fillfactor</literal></link>.
1135+
If you don't, <acronym>HOT</acronym> updates will still happen because
1136+
new rows will naturally migrate to new pages and existing pages with
1137+
sufficient free space for new row versions. The system view <link
1138+
linkend="pg-stat-all-tables-view">pg_stat_all_tables</link>
1139+
allows monitoring of the occurrence of HOT and non-HOT updates.
1140+
</para>
1141+
</sect1>
1142+
10731143
</chapter>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp