blob: 03e07f1fe77d13bbc3eb58bfd0c4d95c07393c44 (
plain)
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
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>73.7. Heap-Only Tuples (HOT)</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="storage-page-layout.html" title="73.6. Database Page Layout" /><link rel="next" href="transactions.html" title="Chapter 74. Transaction Processing" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">73.7. Heap-Only Tuples (<acronym class="acronym">HOT</acronym>)</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="storage-page-layout.html" title="73.6. Database Page Layout">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="storage.html" title="Chapter 73. Database Physical Storage">Up</a></td><th width="60%" align="center">Chapter 73. Database Physical Storage</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="transactions.html" title="Chapter 74. Transaction Processing">Next</a></td></tr></table><hr /></div><div class="sect1" id="STORAGE-HOT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">73.7. Heap-Only Tuples (<acronym class="acronym">HOT</acronym>) <a href="#STORAGE-HOT" class="id_link">#</a></h2></div></div></div><p>
To allow for high concurrency, <span class="productname">PostgreSQL</span>
uses <a class="link" href="mvcc-intro.html" title="13.1. Introduction">multiversion concurrency
control</a> (<acronym class="acronym">MVCC</acronym>) to store rows. However,
<acronym class="acronym">MVCC</acronym> has some downsides for update queries.
Specifically, updates require new versions of rows to be added to
tables. This can also require new index entries for each updated row,
and removal of old versions of rows and their index entries can be
expensive.
</p><p>
To help reduce the overhead of updates,
<span class="productname">PostgreSQL</span> has an optimization called
heap-only tuples (<acronym class="acronym">HOT</acronym>). This optimization is
possible when:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
The update does not modify any columns referenced by the table's indexes,
not including summarizing indexes. The only summarizing index method in
the core <span class="productname">PostgreSQL</span> distribution is <a class="link" href="brin.html" title="Chapter 71. BRIN Indexes">BRIN</a>.
</p></li><li class="listitem"><p>
There is sufficient free space on the page containing the old row
for the updated row.
</p></li></ul></div><p>
In such cases, heap-only tuples provide two optimizations:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
New index entries are not needed to represent updated rows, however,
summary indexes may still need to be updated.
</p></li><li class="listitem"><p>
Old versions of updated rows can be completely removed during normal
operation, including <code class="command">SELECT</code>s, instead of requiring
periodic vacuum operations. (This is possible because indexes
do not reference their <a class="link" href="storage-page-layout.html" title="73.6. Database Page Layout">page
item identifiers</a>.)
</p></li></ul></div><p>
</p><p>
You can increase the likelihood of sufficient page space for
<acronym class="acronym">HOT</acronym> updates by decreasing a table's <a class="link" href="sql-createtable.html#RELOPTION-FILLFACTOR"><code class="literal">fillfactor</code></a>. If you
don't, <acronym class="acronym">HOT</acronym> updates will still happen because new rows
will naturally migrate to new pages and existing pages with sufficient free
space for new row versions. The system view <a class="link" href="monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW" title="28.2.18. pg_stat_all_tables">pg_stat_all_tables</a>
allows monitoring of the occurrence of HOT and non-HOT updates.
</p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="storage-page-layout.html" title="73.6. Database Page Layout">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="storage.html" title="Chapter 73. Database Physical Storage">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="transactions.html" title="Chapter 74. Transaction Processing">Next</a></td></tr><tr><td width="40%" align="left" valign="top">73.6. Database Page Layout </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 74. Transaction Processing</td></tr></table></div></body></html>
|