blob: 412e97d4ee8884c37370d66468e76fc433f6e16b (
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="bki.html" title="Chapter 74. System Catalog Declarations and Initial Contents" /></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 15.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="bki.html" title="Chapter 74. System Catalog Declarations and Initial Contents">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>)</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, including expression and partial indexes.
</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.
</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>
In summary, heap-only tuple updates can only be created
if columns used by indexes are not updated. 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.17. 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="bki.html" title="Chapter 74. System Catalog Declarations and Initial Contents">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 15.5 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 74. System Catalog Declarations and Initial Contents</td></tr></table></div></body></html>
|