-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrin-intro.html
More file actions
123 lines (123 loc) · 13.3 KB
/
brin-intro.html
File metadata and controls
123 lines (123 loc) · 13.3 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?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>67.1. はじめに</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="brin.html" title="第67章 BRINインデックス" /><link rel="next" href="brin-builtin-opclasses.html" title="67.2. 組み込み演算子クラス" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 13.1文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="brin.html" title="第67章 BRINインデックス">第67章 BRINインデックス</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?title=version 13.1 brin-intro.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="brin.html" title="第67章 BRINインデックス">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="brin.html" title="第67章 BRINインデックス">上へ</a></td><td width="60%" align="center">67.1. はじめに</td><td width="20%" align="right"> <a accesskey="n" href="brin-builtin-opclasses.html" title="67.2. 組み込み演算子クラス">次へ</a></td></tr></table><hr /></div><div class="sect1" id="BRIN-INTRO"><div class="titlepage"><div><div><h2 class="title" style="clear: both">67.1. はじめに</h2></div></div></div><span class="original">
<title>Introduction</title>
</span><p>
<span class="original">
<acronym>BRIN</acronym> stands for Block Range Index.
<acronym>BRIN</acronym> is designed for handling very large tables
in which certain columns have some natural correlation with their
physical location within the table.
A <firstterm>block range</firstterm> is a group of pages that are physically
adjacent in the table; for each block range, some summary info is stored
by the index.
For example, a table storing a store's sale orders might have
a date column on which each order was placed, and most of the time
the entries for earlier orders will appear earlier in the table as well;
a table storing a ZIP code column might have all codes for a city
grouped together naturally.
</span>
<acronym class="acronym">BRIN</acronym>は「ブロックレンジインデックス」(Block Range Index)の略です。
<acronym class="acronym">BRIN</acronym>は、ある列がテーブル内の物理的な位置と自然な関係があるような、非常に大規模なテーブルのために設計されています。
<em class="firstterm">ブロックレンジ(block range)</em>は、テーブル内で物理的に隣接するページのグループです。それぞれのブロックレンジに対して、ある種の要約情報がインデックス内に格納されます。
たとえば、店舗の受注情報を格納するテーブルは、各々の受注時期を格納する日付列を持つでしょう。大抵の場合、より前の受注エントリは、テーブルのより前の方にあるでしょう。
郵便番号を管理するテーブルでは、ある市に属する郵便番号が自然にグループ化されることになるでしょう。
</p><p>
<span class="original">
<acronym>BRIN</acronym> indexes can satisfy queries via regular bitmap
index scans, and will return all tuples in all pages within each range if
the summary info stored by the index is <firstterm>consistent</firstterm> with the
query conditions.
The query executor is in charge of rechecking these tuples and discarding
those that do not match the query conditions &mdash; in other words, these
indexes are lossy.
Because a <acronym>BRIN</acronym> index is very small, scanning the index
adds little overhead compared to a sequential scan, but may avoid scanning
large parts of the table that are known not to contain matching tuples.
</span>
<acronym class="acronym">BRIN</acronym>インデックスは、通常のビットマップインデックススキャンを通じて要求されるクエリに使用することができます。
すなわち、インデックス内のレンジ要約情報が検索条件と<em class="firstterm">一致</em>すれば、<acronym class="acronym">BRIN</acronym>インデックスは、レンジ内の全タプルを返します。
クエリエクゼキュータの役割は、検索条件を再チェックし、条件に合致しないタプルを捨てることです。
つまり言い換えると、<acronym class="acronym">BRIN</acronym>インデックスには損失性があります。
<acronym class="acronym">BRIN</acronym>インデックスは非常に小さいため、それに対するスキャンは順スキャンに比べると小さなオーバヘッドしか与えません。しかし、あらかじめ条件に合致しないと分かっているテーブルの多くの部分をスキャンすることを避けることができます。
</p><p>
<span class="original">
The specific data that a <acronym>BRIN</acronym> index will store,
as well as the specific queries that the index will be able to satisfy,
depend on the operator class selected for each column of the index.
Data types having a linear sort order can have operator classes that
store the minimum and maximum value within each block range, for instance;
geometrical types might store the bounding box for all the objects
in the block range.
</span>
<acronym class="acronym">BRIN</acronym>インデックスに格納される特定のデータと、そのインデックスが対応できる特定のクエリは、インデックスに対応する各々の列に与えられた演算子クラスに依存します。
線形のソート順を持つデータ型は、ブロックレンジ内の最小値と最大値と格納する演算子クラスを持つことができます。
たとえば、幾何データ型は、ブロックレンジ内のすべてのオブジェクトを含む外接矩形を持つことでしょう。
</p><p>
<span class="original">
The size of the block range is determined at index creation time by
the <literal>pages_per_range</literal> storage parameter. The number of index
entries will be equal to the size of the relation in pages divided by
the selected value for <literal>pages_per_range</literal>. Therefore, the smaller
the number, the larger the index becomes (because of the need to
store more index entries), but at the same time the summary data stored can
be more precise and more data blocks can be skipped during an index scan.
</span>
ブロックレンジの大きさは、ストレージパラメータ<code class="literal">pages_per_range</code>でインデックス作成時に決定されます。
インデックスエントリの数は、リレーションのページ数を<code class="literal">pages_per_range</code>に設定した数で割ったものと等しくなります。
ですから、<code class="literal">pages_per_range</code>の設定値が小さいほど、インデックスは大きくなります(より多くのインデックスエントリを格納する必要があるので)が、反面、格納されたサマリデータはより精密になり、インデックススキャンの際により多くのデータブロックをスキップすることができるようになります。
</p><div class="sect2" id="BRIN-OPERATION"><div class="titlepage"><div><div><h3 class="title">67.1.1. インデックスの保守</h3></div></div></div><span class="original">
<title>Index Maintenance</title>
</span><p>
<span class="original">
At the time of creation, all existing heap pages are scanned and a
summary index tuple is created for each range, including the
possibly-incomplete range at the end.
As new pages are filled with data, page ranges that are already
summarized will cause the summary information to be updated with data
from the new tuples.
When a new page is created that does not fall within the last
summarized range, that range does not automatically acquire a summary
tuple; those tuples remain unsummarized until a summarization run is
invoked later, creating initial summaries.
This process can be invoked manually using the
<function>brin_summarize_range(regclass, bigint)</function> or
<function>brin_summarize_new_values(regclass)</function> functions;
automatically when <command>VACUUM</command> processes the table;
or by automatic summarization executed by autovacuum, as insertions
occur. (This last trigger is disabled by default and can be enabled
with the <literal>autosummarize</literal> parameter.)
Conversely, a range can be de-summarized using the
<function>brin_desummarize_range(regclass, bigint)</function> function,
which is useful when the index tuple is no longer a very good
representation because the existing values have changed.
</span>
インデックスを作成した当初は、すべてのヒープページがスキャンされ、終端が不完全なものも含め、各々のレンジに対してサマリーインデックスタプルが作成されます。
新しいページにデータが登録されると、新しいタプルのデータを元に、すでにサマリ済みのページレンジのサマリー情報が更新されます。
最終サマリーレンジに適合しない新しいページが作成されると、そのレンジに対して自動的にはサマリタプルが作成されません。
これらのタプルは、後でサマリー処理が走って初期サマリー情報が作成されるまではサマリーされません。
この処理は<code class="function">brin_summarize_range(regclass, bigint)</code>または<code class="function">brin_summarize_new_values(regclass)</code>関数を起動することで、手動で実行できます。
あるいは、<code class="command">VACUUM</code>がそのテーブルを処理する際に自動的に起動でき、また、行挿入があった際にautovacuumによって自動サマリ処理が実行されるときにも起動できます。
(最後の自動処理起動はデフォルトでは無効になっていますが、<code class="literal">autosummarize</code>パラメータで有効にできます。)
反対に、レンジは<code class="function">brin_desummarize_range(regclass, bigint)</code>関数で非サマリー化できます。
これは、既存の値が変更されたためにインデックスタプルがもはや値の表現としては適当でなくなった場合に有効です。
</p><p>
<span class="original">
When autosummarization is enabled, each time a page range is filled a
request is sent to autovacuum for it to execute a targeted summarization
for that range, to be fulfilled at the end of the next worker run on the
same database. If the request queue is full, the request is not recorded
and a message is sent to the server log:
</span>
自動サマリー機能が有効な場合、ページレンジが満たされる度に、そのレンジをターゲットとするサマリー機能を実行する要求が自動バキュームに送信されます。
そしてそのリクエストは、同じデータベースに対してワーカーが次に走る際に、最後のところで実行されます。
もしリクエストキューが満杯ならばそのリクエストは記録されず、次のメッセージがサーバのログに送信されます。
</p><pre class="screen">
LOG: request for BRIN range summarization for index "brin_wi_idx" page 128 was not recorded
</pre><p>
<span class="original">
When this happens, the range will be summarized normally during the next
regular vacuum of the table.
</span>
この状態が発生すると、そのレンジはテーブルの次の通常バキュームで正常にサマライズされます。
</p></div></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="brin.html" title="第67章 BRINインデックス">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="brin.html" title="第67章 BRINインデックス">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="brin-builtin-opclasses.html" title="67.2. 組み込み演算子クラス">次へ</a></td></tr><tr><td width="40%" align="left" valign="top">第67章 BRINインデックス </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 13.1文書">ホーム</a></td><td width="40%" align="right" valign="top"> 67.2. 組み込み演算子クラス</td></tr></table></div></body></html>