Skip to content

Commit 5001b44

Browse files
committed
BRIN: improve documentation on summarization
The existing wording wasn't clear enough and some details weren't anywhere, such as the fact that autosummarization is off by default. Improve. Authors: Roberto Mello, Jaime Casanova, Justin Pryzby, Álvaro Herrera Discussion: https://postgr.es/m/CAKz==bK_NoJytRyQfX8K-erCW3Ff7--oGYpiB8+ePVS7dRVW_A@mail.gmail.com Discussion: https://postgr.es/m/20220224193520.GY9008@telsasoft.com
1 parent 6ffff0f commit 5001b44

File tree

2 files changed

+59
-21
lines changed

2 files changed

+59
-21
lines changed

doc/src/sgml/brin.sgml

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
<acronym>BRIN</acronym> is designed for handling very large tables
1717
in which certain columns have some natural correlation with their
1818
physical location within the table.
19-
A <firstterm>block range</firstterm> is a group of pages that are physically
19+
</para>
20+
21+
<para>
22+
<acronym>BRIN</acronym> works in terms of <firstterm>block ranges</firstterm>
23+
(or <quote>page ranges</quote>).
24+
A block range is a group of pages that are physically
2025
adjacent in the table; for each block range, some summary info is stored
2126
by the index.
2227
For example, a table storing a store's sale orders might have
@@ -70,34 +75,65 @@
7075
summarized will cause the summary information to be updated with data
7176
from the new tuples.
7277
When a new page is created that does not fall within the last
73-
summarized range, that range does not automatically acquire a summary
74-
tuple; those tuples remain unsummarized until a summarization run is
75-
invoked later, creating initial summaries.
76-
This process can be invoked manually using the
77-
<function>brin_summarize_range(regclass, bigint)</function> or
78-
<function>brin_summarize_new_values(regclass)</function> functions;
79-
automatically when <command>VACUUM</command> processes the table;
80-
or by automatic summarization executed by autovacuum, as insertions
81-
occur. (This last trigger is disabled by default and can be enabled
82-
with the <literal>autosummarize</literal> parameter.)
83-
Conversely, a range can be de-summarized using the
84-
<function>brin_desummarize_range(regclass, bigint)</function> function,
85-
which is useful when the index tuple is no longer a very good
86-
representation because the existing values have changed.
78+
summarized range, the range that the new page belongs into
79+
does not automatically acquire a summary tuple;
80+
those tuples remain unsummarized until a summarization run is
81+
invoked later, creating the initial summary for that range.
8782
</para>
8883

8984
<para>
90-
When autosummarization is enabled, each time a page range is filled a
91-
request is sent to autovacuum for it to execute a targeted summarization
92-
for that range, to be fulfilled at the end of the next worker run on the
85+
There are several ways to trigger the initial summarization of a page range.
86+
If the table is vacuumed, either manually or by
87+
<link linkend="autovacuum">autovacuum</link>, all existing unsummarized
88+
page ranges are summarized.
89+
Also, if the index's
90+
<xref linkend="index-reloption-autosummarize"/> parameter is enabled,
91+
which it isn't by default,
92+
whenever autovacuum runs in that database, summarization will occur for all
93+
unsummarized page ranges that have been filled,
94+
regardless of whether the table itself is processed by autovacuum; see below.
95+
</para>
96+
97+
<para>
98+
Lastly, the following functions can be used:
99+
<simplelist>
100+
<member>
101+
<function>brin_summarize_new_values(regclass)</function>
102+
which summarizes all unsummarized ranges;
103+
</member>
104+
<member>
105+
<function>brin_summarize_range(regclass, bigint)</function>
106+
which summarizes only the range containing the given page,
107+
if it is unsummarized.
108+
</member>
109+
</simplelist>
110+
</para>
111+
112+
<para>
113+
When autosummarization is enabled, a request is sent to
114+
<literal>autovacuum</literal> to execute a targeted summarization
115+
for a block range when an insertion is detected for the first item
116+
of the first page of the next block range,
117+
to be fulfilled the next time an autovacuum
118+
worker finishes running in the
93119
same database. If the request queue is full, the request is not recorded
94120
and a message is sent to the server log:
95121
<screen>
96122
LOG: request for BRIN range summarization for index "brin_wi_idx" page 128 was not recorded
97123
</screen>
98-
When this happens, the range will be summarized normally during the next
99-
regular vacuum of the table.
124+
When this happens, the range will remain unsummarized until the next
125+
regular vacuum run on the table, or one of the functions mentioned above
126+
are invoked.
127+
</para>
128+
129+
<para>
130+
Conversely, a range can be de-summarized using the
131+
<function>brin_desummarize_range(regclass, bigint)</function> function,
132+
which is useful when the index tuple is no longer a very good
133+
representation because the existing values have changed.
134+
See <xref linkend="functions-admin-index"/> for details.
100135
</para>
136+
101137
</sect2>
102138
</sect1>
103139

doc/src/sgml/ref/create_index.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,10 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
578578
</term>
579579
<listitem>
580580
<para>
581-
Defines whether a summarization run is invoked for the previous page
581+
Defines whether a summarization run is queued for the previous page
582582
range whenever an insertion is detected on the next one.
583+
See <xref linkend="brin-operation"/> for more details.
584+
The default is <literal>off</literal>.
583585
</para>
584586
</listitem>
585587
</varlistentry>

0 commit comments

Comments
 (0)