]> begriffs open source - ai-pg/blob - full-docs/txt/storage-hot.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / storage-hot.txt
1
2 66.7. Heap-Only Tuples (HOT) #
3
4    To allow for high concurrency, PostgreSQL uses multiversion concurrency
5    control (MVCC) to store rows. However, MVCC has some downsides for
6    update queries. Specifically, updates require new versions of rows to
7    be added to tables. This can also require new index entries for each
8    updated row, and removal of old versions of rows and their index
9    entries can be expensive.
10
11    To help reduce the overhead of updates, PostgreSQL has an optimization
12    called heap-only tuples (HOT). This optimization is possible when:
13      * The update does not modify any columns referenced by the table's
14        indexes, not including summarizing indexes. The only summarizing
15        index method in the core PostgreSQL distribution is BRIN.
16      * There is sufficient free space on the page containing the old row
17        for the updated row.
18
19    In such cases, heap-only tuples provide two optimizations:
20      * New index entries are not needed to represent updated rows,
21        however, summary indexes may still need to be updated.
22      * When a row is updated multiple times, row versions other than the
23        oldest and the newest can be completely removed during normal
24        operation, including SELECTs, instead of requiring periodic vacuum
25        operations. (Indexes always refer to the page item identifier of
26        the original row version. The tuple data associated with that row
27        version is removed, and its item identifier is converted to a
28        redirect that points to the oldest version that may still be
29        visible to some concurrent transaction. Intermediate row versions
30        that are no longer visible to anyone are completely removed, and
31        the associated page item identifiers are made available for reuse.)
32
33    You can increase the likelihood of sufficient page space for HOT
34    updates by decreasing a table's fillfactor. If you don't, HOT updates
35    will still happen because new rows will naturally migrate to new pages
36    and existing pages with sufficient free space for new row versions. The
37    system view pg_stat_all_tables allows monitoring of the occurrence of
38    HOT and non-HOT updates.