mirror of
https://github.com/postgres/postgres.git
synced 2025-10-29 22:49:41 +03:00
Don't use SGML empty tags
For DocBook XML compatibility, don't use SGML empty tags (</>) anymore, replace by the full tag name. Add a warning option to catch future occurrences. Alexander Lakhin, Jürgen Purtz
This commit is contained in:
@@ -21,15 +21,15 @@
|
||||
</para>
|
||||
|
||||
<para>
|
||||
We use the word <firstterm>item</> to refer to a composite value that
|
||||
is to be indexed, and the word <firstterm>key</> to refer to an element
|
||||
We use the word <firstterm>item</firstterm> to refer to a composite value that
|
||||
is to be indexed, and the word <firstterm>key</firstterm> to refer to an element
|
||||
value. <acronym>GIN</acronym> always stores and searches for keys,
|
||||
not item values per se.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A <acronym>GIN</acronym> index stores a set of (key, posting list) pairs,
|
||||
where a <firstterm>posting list</> is a set of row IDs in which the key
|
||||
where a <firstterm>posting list</firstterm> is a set of row IDs in which the key
|
||||
occurs. The same row ID can appear in multiple posting lists, since
|
||||
an item can contain more than one key. Each key value is stored only
|
||||
once, so a <acronym>GIN</acronym> index is very compact for cases
|
||||
@@ -66,7 +66,7 @@
|
||||
<title>Built-in Operator Classes</title>
|
||||
|
||||
<para>
|
||||
The core <productname>PostgreSQL</> distribution
|
||||
The core <productname>PostgreSQL</productname> distribution
|
||||
includes the <acronym>GIN</acronym> operator classes shown in
|
||||
<xref linkend="gin-builtin-opclasses-table">.
|
||||
(Some of the optional modules described in <xref linkend="contrib">
|
||||
@@ -85,38 +85,38 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>array_ops</></entry>
|
||||
<entry><type>anyarray</></entry>
|
||||
<entry><literal>array_ops</literal></entry>
|
||||
<entry><type>anyarray</type></entry>
|
||||
<entry>
|
||||
<literal>&&</>
|
||||
<literal><@</>
|
||||
<literal>=</>
|
||||
<literal>@></>
|
||||
<literal>&&</literal>
|
||||
<literal><@</literal>
|
||||
<literal>=</literal>
|
||||
<literal>@></literal>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>jsonb_ops</></entry>
|
||||
<entry><type>jsonb</></entry>
|
||||
<entry><literal>jsonb_ops</literal></entry>
|
||||
<entry><type>jsonb</type></entry>
|
||||
<entry>
|
||||
<literal>?</>
|
||||
<literal>?&</>
|
||||
<literal>?|</>
|
||||
<literal>@></>
|
||||
<literal>?</literal>
|
||||
<literal>?&</literal>
|
||||
<literal>?|</literal>
|
||||
<literal>@></literal>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>jsonb_path_ops</></entry>
|
||||
<entry><type>jsonb</></entry>
|
||||
<entry><literal>jsonb_path_ops</literal></entry>
|
||||
<entry><type>jsonb</type></entry>
|
||||
<entry>
|
||||
<literal>@></>
|
||||
<literal>@></literal>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>tsvector_ops</></entry>
|
||||
<entry><type>tsvector</></entry>
|
||||
<entry><literal>tsvector_ops</literal></entry>
|
||||
<entry><type>tsvector</type></entry>
|
||||
<entry>
|
||||
<literal>@@</>
|
||||
<literal>@@@</>
|
||||
<literal>@@</literal>
|
||||
<literal>@@@</literal>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
@@ -124,8 +124,8 @@
|
||||
</table>
|
||||
|
||||
<para>
|
||||
Of the two operator classes for type <type>jsonb</>, <literal>jsonb_ops</>
|
||||
is the default. <literal>jsonb_path_ops</> supports fewer operators but
|
||||
Of the two operator classes for type <type>jsonb</type>, <literal>jsonb_ops</literal>
|
||||
is the default. <literal>jsonb_path_ops</literal> supports fewer operators but
|
||||
offers better performance for those operators.
|
||||
See <xref linkend="json-indexing"> for details.
|
||||
</para>
|
||||
@@ -157,15 +157,15 @@
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><function>Datum *extractValue(Datum itemValue, int32 *nkeys,
|
||||
bool **nullFlags)</></term>
|
||||
bool **nullFlags)</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Returns a palloc'd array of keys given an item to be indexed. The
|
||||
number of returned keys must be stored into <literal>*nkeys</>.
|
||||
number of returned keys must be stored into <literal>*nkeys</literal>.
|
||||
If any of the keys can be null, also palloc an array of
|
||||
<literal>*nkeys</> <type>bool</type> fields, store its address at
|
||||
<literal>*nullFlags</>, and set these null flags as needed.
|
||||
<literal>*nullFlags</> can be left <symbol>NULL</symbol> (its initial value)
|
||||
<literal>*nkeys</literal> <type>bool</type> fields, store its address at
|
||||
<literal>*nullFlags</literal>, and set these null flags as needed.
|
||||
<literal>*nullFlags</literal> can be left <symbol>NULL</symbol> (its initial value)
|
||||
if all keys are non-null.
|
||||
The return value can be <symbol>NULL</symbol> if the item contains no keys.
|
||||
</para>
|
||||
@@ -175,40 +175,40 @@
|
||||
<varlistentry>
|
||||
<term><function>Datum *extractQuery(Datum query, int32 *nkeys,
|
||||
StrategyNumber n, bool **pmatch, Pointer **extra_data,
|
||||
bool **nullFlags, int32 *searchMode)</></term>
|
||||
bool **nullFlags, int32 *searchMode)</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Returns a palloc'd array of keys given a value to be queried; that is,
|
||||
<literal>query</> is the value on the right-hand side of an
|
||||
<literal>query</literal> is the value on the right-hand side of an
|
||||
indexable operator whose left-hand side is the indexed column.
|
||||
<literal>n</> is the strategy number of the operator within the
|
||||
<literal>n</literal> is the strategy number of the operator within the
|
||||
operator class (see <xref linkend="xindex-strategies">).
|
||||
Often, <function>extractQuery</> will need
|
||||
to consult <literal>n</> to determine the data type of
|
||||
<literal>query</> and the method it should use to extract key values.
|
||||
The number of returned keys must be stored into <literal>*nkeys</>.
|
||||
Often, <function>extractQuery</function> will need
|
||||
to consult <literal>n</literal> to determine the data type of
|
||||
<literal>query</literal> and the method it should use to extract key values.
|
||||
The number of returned keys must be stored into <literal>*nkeys</literal>.
|
||||
If any of the keys can be null, also palloc an array of
|
||||
<literal>*nkeys</> <type>bool</type> fields, store its address at
|
||||
<literal>*nullFlags</>, and set these null flags as needed.
|
||||
<literal>*nullFlags</> can be left <symbol>NULL</symbol> (its initial value)
|
||||
<literal>*nkeys</literal> <type>bool</type> fields, store its address at
|
||||
<literal>*nullFlags</literal>, and set these null flags as needed.
|
||||
<literal>*nullFlags</literal> can be left <symbol>NULL</symbol> (its initial value)
|
||||
if all keys are non-null.
|
||||
The return value can be <symbol>NULL</symbol> if the <literal>query</> contains no keys.
|
||||
The return value can be <symbol>NULL</symbol> if the <literal>query</literal> contains no keys.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>searchMode</> is an output argument that allows
|
||||
<function>extractQuery</> to specify details about how the search
|
||||
<literal>searchMode</literal> is an output argument that allows
|
||||
<function>extractQuery</function> to specify details about how the search
|
||||
will be done.
|
||||
If <literal>*searchMode</> is set to
|
||||
<literal>GIN_SEARCH_MODE_DEFAULT</> (which is the value it is
|
||||
If <literal>*searchMode</literal> is set to
|
||||
<literal>GIN_SEARCH_MODE_DEFAULT</literal> (which is the value it is
|
||||
initialized to before call), only items that match at least one of
|
||||
the returned keys are considered candidate matches.
|
||||
If <literal>*searchMode</> is set to
|
||||
<literal>GIN_SEARCH_MODE_INCLUDE_EMPTY</>, then in addition to items
|
||||
If <literal>*searchMode</literal> is set to
|
||||
<literal>GIN_SEARCH_MODE_INCLUDE_EMPTY</literal>, then in addition to items
|
||||
containing at least one matching key, items that contain no keys at
|
||||
all are considered candidate matches. (This mode is useful for
|
||||
implementing is-subset-of operators, for example.)
|
||||
If <literal>*searchMode</> is set to <literal>GIN_SEARCH_MODE_ALL</>,
|
||||
If <literal>*searchMode</literal> is set to <literal>GIN_SEARCH_MODE_ALL</literal>,
|
||||
then all non-null items in the index are considered candidate
|
||||
matches, whether they match any of the returned keys or not. (This
|
||||
mode is much slower than the other two choices, since it requires
|
||||
@@ -217,33 +217,33 @@
|
||||
in most cases is probably not a good candidate for a GIN operator
|
||||
class.)
|
||||
The symbols to use for setting this mode are defined in
|
||||
<filename>access/gin.h</>.
|
||||
<filename>access/gin.h</filename>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>pmatch</> is an output argument for use when partial match
|
||||
is supported. To use it, <function>extractQuery</> must allocate
|
||||
an array of <literal>*nkeys</> booleans and store its address at
|
||||
<literal>*pmatch</>. Each element of the array should be set to TRUE
|
||||
<literal>pmatch</literal> is an output argument for use when partial match
|
||||
is supported. To use it, <function>extractQuery</function> must allocate
|
||||
an array of <literal>*nkeys</literal> booleans and store its address at
|
||||
<literal>*pmatch</literal>. Each element of the array should be set to TRUE
|
||||
if the corresponding key requires partial match, FALSE if not.
|
||||
If <literal>*pmatch</> is set to <symbol>NULL</symbol> then GIN assumes partial match
|
||||
If <literal>*pmatch</literal> is set to <symbol>NULL</symbol> then GIN assumes partial match
|
||||
is not required. The variable is initialized to <symbol>NULL</symbol> before call,
|
||||
so this argument can simply be ignored by operator classes that do
|
||||
not support partial match.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<literal>extra_data</> is an output argument that allows
|
||||
<function>extractQuery</> to pass additional data to the
|
||||
<function>consistent</> and <function>comparePartial</> methods.
|
||||
To use it, <function>extractQuery</> must allocate
|
||||
an array of <literal>*nkeys</> pointers and store its address at
|
||||
<literal>*extra_data</>, then store whatever it wants to into the
|
||||
<literal>extra_data</literal> is an output argument that allows
|
||||
<function>extractQuery</function> to pass additional data to the
|
||||
<function>consistent</function> and <function>comparePartial</function> methods.
|
||||
To use it, <function>extractQuery</function> must allocate
|
||||
an array of <literal>*nkeys</literal> pointers and store its address at
|
||||
<literal>*extra_data</literal>, then store whatever it wants to into the
|
||||
individual pointers. The variable is initialized to <symbol>NULL</symbol> before
|
||||
call, so this argument can simply be ignored by operator classes that
|
||||
do not require extra data. If <literal>*extra_data</> is set, the
|
||||
whole array is passed to the <function>consistent</> method, and
|
||||
the appropriate element to the <function>comparePartial</> method.
|
||||
do not require extra data. If <literal>*extra_data</literal> is set, the
|
||||
whole array is passed to the <function>consistent</function> method, and
|
||||
the appropriate element to the <function>comparePartial</function> method.
|
||||
</para>
|
||||
|
||||
</listitem>
|
||||
@@ -251,10 +251,10 @@
|
||||
</variablelist>
|
||||
|
||||
An operator class must also provide a function to check if an indexed item
|
||||
matches the query. It comes in two flavors, a boolean <function>consistent</>
|
||||
function, and a ternary <function>triConsistent</> function.
|
||||
<function>triConsistent</> covers the functionality of both, so providing
|
||||
<function>triConsistent</> alone is sufficient. However, if the boolean
|
||||
matches the query. It comes in two flavors, a boolean <function>consistent</function>
|
||||
function, and a ternary <function>triConsistent</function> function.
|
||||
<function>triConsistent</function> covers the functionality of both, so providing
|
||||
<function>triConsistent</function> alone is sufficient. However, if the boolean
|
||||
variant is significantly cheaper to calculate, it can be advantageous to
|
||||
provide both. If only the boolean variant is provided, some optimizations
|
||||
that depend on refuting index items before fetching all the keys are
|
||||
@@ -264,48 +264,48 @@
|
||||
<varlistentry>
|
||||
<term><function>bool consistent(bool check[], StrategyNumber n, Datum query,
|
||||
int32 nkeys, Pointer extra_data[], bool *recheck,
|
||||
Datum queryKeys[], bool nullFlags[])</></term>
|
||||
Datum queryKeys[], bool nullFlags[])</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Returns TRUE if an indexed item satisfies the query operator with
|
||||
strategy number <literal>n</> (or might satisfy it, if the recheck
|
||||
strategy number <literal>n</literal> (or might satisfy it, if the recheck
|
||||
indication is returned). This function does not have direct access
|
||||
to the indexed item's value, since <acronym>GIN</acronym> does not
|
||||
store items explicitly. Rather, what is available is knowledge
|
||||
about which key values extracted from the query appear in a given
|
||||
indexed item. The <literal>check</> array has length
|
||||
<literal>nkeys</>, which is the same as the number of keys previously
|
||||
returned by <function>extractQuery</> for this <literal>query</> datum.
|
||||
indexed item. The <literal>check</literal> array has length
|
||||
<literal>nkeys</literal>, which is the same as the number of keys previously
|
||||
returned by <function>extractQuery</function> for this <literal>query</literal> datum.
|
||||
Each element of the
|
||||
<literal>check</> array is TRUE if the indexed item contains the
|
||||
<literal>check</literal> array is TRUE if the indexed item contains the
|
||||
corresponding query key, i.e., if (check[i] == TRUE) the i-th key of the
|
||||
<function>extractQuery</> result array is present in the indexed item.
|
||||
The original <literal>query</> datum is
|
||||
passed in case the <function>consistent</> method needs to consult it,
|
||||
and so are the <literal>queryKeys[]</> and <literal>nullFlags[]</>
|
||||
arrays previously returned by <function>extractQuery</>.
|
||||
<literal>extra_data</> is the extra-data array returned by
|
||||
<function>extractQuery</>, or <symbol>NULL</symbol> if none.
|
||||
<function>extractQuery</function> result array is present in the indexed item.
|
||||
The original <literal>query</literal> datum is
|
||||
passed in case the <function>consistent</function> method needs to consult it,
|
||||
and so are the <literal>queryKeys[]</literal> and <literal>nullFlags[]</literal>
|
||||
arrays previously returned by <function>extractQuery</function>.
|
||||
<literal>extra_data</literal> is the extra-data array returned by
|
||||
<function>extractQuery</function>, or <symbol>NULL</symbol> if none.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
When <function>extractQuery</> returns a null key in
|
||||
<literal>queryKeys[]</>, the corresponding <literal>check[]</> element
|
||||
When <function>extractQuery</function> returns a null key in
|
||||
<literal>queryKeys[]</literal>, the corresponding <literal>check[]</literal> element
|
||||
is TRUE if the indexed item contains a null key; that is, the
|
||||
semantics of <literal>check[]</> are like <literal>IS NOT DISTINCT
|
||||
FROM</>. The <function>consistent</> function can examine the
|
||||
corresponding <literal>nullFlags[]</> element if it needs to tell
|
||||
semantics of <literal>check[]</literal> are like <literal>IS NOT DISTINCT
|
||||
FROM</literal>. The <function>consistent</function> function can examine the
|
||||
corresponding <literal>nullFlags[]</literal> element if it needs to tell
|
||||
the difference between a regular value match and a null match.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
On success, <literal>*recheck</> should be set to TRUE if the heap
|
||||
On success, <literal>*recheck</literal> should be set to TRUE if the heap
|
||||
tuple needs to be rechecked against the query operator, or FALSE if
|
||||
the index test is exact. That is, a FALSE return value guarantees
|
||||
that the heap tuple does not match the query; a TRUE return value with
|
||||
<literal>*recheck</> set to FALSE guarantees that the heap tuple does
|
||||
<literal>*recheck</literal> set to FALSE guarantees that the heap tuple does
|
||||
match the query; and a TRUE return value with
|
||||
<literal>*recheck</> set to TRUE means that the heap tuple might match
|
||||
<literal>*recheck</literal> set to TRUE means that the heap tuple might match
|
||||
the query, so it needs to be fetched and rechecked by evaluating the
|
||||
query operator directly against the originally indexed item.
|
||||
</para>
|
||||
@@ -315,30 +315,30 @@
|
||||
<varlistentry>
|
||||
<term><function>GinTernaryValue triConsistent(GinTernaryValue check[], StrategyNumber n, Datum query,
|
||||
int32 nkeys, Pointer extra_data[],
|
||||
Datum queryKeys[], bool nullFlags[])</></term>
|
||||
Datum queryKeys[], bool nullFlags[])</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
<function>triConsistent</> is similar to <function>consistent</>,
|
||||
but instead of booleans in the <literal>check</> vector, there are
|
||||
<function>triConsistent</function> is similar to <function>consistent</function>,
|
||||
but instead of booleans in the <literal>check</literal> vector, there are
|
||||
three possible values for each
|
||||
key: <literal>GIN_TRUE</>, <literal>GIN_FALSE</> and
|
||||
<literal>GIN_MAYBE</>. <literal>GIN_FALSE</> and <literal>GIN_TRUE</>
|
||||
key: <literal>GIN_TRUE</literal>, <literal>GIN_FALSE</literal> and
|
||||
<literal>GIN_MAYBE</literal>. <literal>GIN_FALSE</literal> and <literal>GIN_TRUE</literal>
|
||||
have the same meaning as regular boolean values, while
|
||||
<literal>GIN_MAYBE</> means that the presence of that key is not known.
|
||||
When <literal>GIN_MAYBE</> values are present, the function should only
|
||||
return <literal>GIN_TRUE</> if the item certainly matches whether or
|
||||
<literal>GIN_MAYBE</literal> means that the presence of that key is not known.
|
||||
When <literal>GIN_MAYBE</literal> values are present, the function should only
|
||||
return <literal>GIN_TRUE</literal> if the item certainly matches whether or
|
||||
not the index item contains the corresponding query keys. Likewise, the
|
||||
function must return <literal>GIN_FALSE</> only if the item certainly
|
||||
does not match, whether or not it contains the <literal>GIN_MAYBE</>
|
||||
keys. If the result depends on the <literal>GIN_MAYBE</> entries, i.e.,
|
||||
function must return <literal>GIN_FALSE</literal> only if the item certainly
|
||||
does not match, whether or not it contains the <literal>GIN_MAYBE</literal>
|
||||
keys. If the result depends on the <literal>GIN_MAYBE</literal> entries, i.e.,
|
||||
the match cannot be confirmed or refuted based on the known query keys,
|
||||
the function must return <literal>GIN_MAYBE</>.
|
||||
the function must return <literal>GIN_MAYBE</literal>.
|
||||
</para>
|
||||
<para>
|
||||
When there are no <literal>GIN_MAYBE</> values in the <literal>check</>
|
||||
vector, a <literal>GIN_MAYBE</> return value is the equivalent of
|
||||
setting the <literal>recheck</> flag in the
|
||||
boolean <function>consistent</> function.
|
||||
When there are no <literal>GIN_MAYBE</literal> values in the <literal>check</literal>
|
||||
vector, a <literal>GIN_MAYBE</literal> return value is the equivalent of
|
||||
setting the <literal>recheck</literal> flag in the
|
||||
boolean <function>consistent</function> function.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@@ -352,7 +352,7 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><function>int compare(Datum a, Datum b)</></term>
|
||||
<term><function>int compare(Datum a, Datum b)</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Compares two keys (not indexed items!) and returns an integer less than
|
||||
@@ -364,13 +364,13 @@
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
Alternatively, if the operator class does not provide a <function>compare</>
|
||||
Alternatively, if the operator class does not provide a <function>compare</function>
|
||||
method, GIN will look up the default btree operator class for the index
|
||||
key data type, and use its comparison function. It is recommended to
|
||||
specify the comparison function in a GIN operator class that is meant for
|
||||
just one data type, as looking up the btree operator class costs a few
|
||||
cycles. However, polymorphic GIN operator classes (such
|
||||
as <literal>array_ops</>) typically cannot specify a single comparison
|
||||
as <literal>array_ops</literal>) typically cannot specify a single comparison
|
||||
function.
|
||||
</para>
|
||||
|
||||
@@ -381,7 +381,7 @@
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><function>int comparePartial(Datum partial_key, Datum key, StrategyNumber n,
|
||||
Pointer extra_data)</></term>
|
||||
Pointer extra_data)</function></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Compare a partial-match query key to an index key. Returns an integer
|
||||
@@ -389,11 +389,11 @@
|
||||
does not match the query, but the index scan should continue; zero
|
||||
means that the index key does match the query; greater than zero
|
||||
indicates that the index scan should stop because no more matches
|
||||
are possible. The strategy number <literal>n</> of the operator
|
||||
are possible. The strategy number <literal>n</literal> of the operator
|
||||
that generated the partial match query is provided, in case its
|
||||
semantics are needed to determine when to end the scan. Also,
|
||||
<literal>extra_data</> is the corresponding element of the extra-data
|
||||
array made by <function>extractQuery</>, or <symbol>NULL</symbol> if none.
|
||||
<literal>extra_data</literal> is the corresponding element of the extra-data
|
||||
array made by <function>extractQuery</function>, or <symbol>NULL</symbol> if none.
|
||||
Null keys are never passed to this function.
|
||||
</para>
|
||||
</listitem>
|
||||
@@ -402,25 +402,25 @@
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To support <quote>partial match</> queries, an operator class must
|
||||
provide the <function>comparePartial</> method, and its
|
||||
<function>extractQuery</> method must set the <literal>pmatch</>
|
||||
To support <quote>partial match</quote> queries, an operator class must
|
||||
provide the <function>comparePartial</function> method, and its
|
||||
<function>extractQuery</function> method must set the <literal>pmatch</literal>
|
||||
parameter when a partial-match query is encountered. See
|
||||
<xref linkend="gin-partial-match"> for details.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The actual data types of the various <literal>Datum</> values mentioned
|
||||
The actual data types of the various <literal>Datum</literal> values mentioned
|
||||
above vary depending on the operator class. The item values passed to
|
||||
<function>extractValue</> are always of the operator class's input type, and
|
||||
all key values must be of the class's <literal>STORAGE</> type. The type of
|
||||
the <literal>query</> argument passed to <function>extractQuery</>,
|
||||
<function>consistent</> and <function>triConsistent</> is whatever is the
|
||||
<function>extractValue</function> are always of the operator class's input type, and
|
||||
all key values must be of the class's <literal>STORAGE</literal> type. The type of
|
||||
the <literal>query</literal> argument passed to <function>extractQuery</function>,
|
||||
<function>consistent</function> and <function>triConsistent</function> is whatever is the
|
||||
right-hand input type of the class member operator identified by the
|
||||
strategy number. This need not be the same as the indexed type, so long as
|
||||
key values of the correct type can be extracted from it. However, it is
|
||||
recommended that the SQL declarations of these three support functions use
|
||||
the opclass's indexed data type for the <literal>query</> argument, even
|
||||
the opclass's indexed data type for the <literal>query</literal> argument, even
|
||||
though the actual type might be something else depending on the operator.
|
||||
</para>
|
||||
|
||||
@@ -434,8 +434,8 @@
|
||||
constructed over keys, where each key is an element of one or more indexed
|
||||
items (a member of an array, for example) and where each tuple in a leaf
|
||||
page contains either a pointer to a B-tree of heap pointers (a
|
||||
<quote>posting tree</>), or a simple list of heap pointers (a <quote>posting
|
||||
list</>) when the list is small enough to fit into a single index tuple along
|
||||
<quote>posting tree</quote>), or a simple list of heap pointers (a <quote>posting
|
||||
list</quote>) when the list is small enough to fit into a single index tuple along
|
||||
with the key value.
|
||||
</para>
|
||||
|
||||
@@ -443,7 +443,7 @@
|
||||
As of <productname>PostgreSQL</productname> 9.1, null key values can be
|
||||
included in the index. Also, placeholder nulls are included in the index
|
||||
for indexed items that are null or contain no keys according to
|
||||
<function>extractValue</>. This allows searches that should find empty
|
||||
<function>extractValue</function>. This allows searches that should find empty
|
||||
items to do so.
|
||||
</para>
|
||||
|
||||
@@ -461,7 +461,7 @@
|
||||
intrinsic nature of inverted indexes: inserting or updating one heap row
|
||||
can cause many inserts into the index (one for each key extracted
|
||||
from the indexed item). As of <productname>PostgreSQL</productname> 8.4,
|
||||
<acronym>GIN</> is capable of postponing much of this work by inserting
|
||||
<acronym>GIN</acronym> is capable of postponing much of this work by inserting
|
||||
new tuples into a temporary, unsorted list of pending entries.
|
||||
When the table is vacuumed or autoanalyzed, or when
|
||||
<function>gin_clean_pending_list</function> function is called, or if the
|
||||
@@ -479,7 +479,7 @@
|
||||
of pending entries in addition to searching the regular index, and so
|
||||
a large list of pending entries will slow searches significantly.
|
||||
Another disadvantage is that, while most updates are fast, an update
|
||||
that causes the pending list to become <quote>too large</> will incur an
|
||||
that causes the pending list to become <quote>too large</quote> will incur an
|
||||
immediate cleanup cycle and thus be much slower than other updates.
|
||||
Proper use of autovacuum can minimize both of these problems.
|
||||
</para>
|
||||
@@ -497,15 +497,15 @@
|
||||
<title>Partial Match Algorithm</title>
|
||||
|
||||
<para>
|
||||
GIN can support <quote>partial match</> queries, in which the query
|
||||
GIN can support <quote>partial match</quote> queries, in which the query
|
||||
does not determine an exact match for one or more keys, but the possible
|
||||
matches fall within a reasonably narrow range of key values (within the
|
||||
key sorting order determined by the <function>compare</> support method).
|
||||
The <function>extractQuery</> method, instead of returning a key value
|
||||
key sorting order determined by the <function>compare</function> support method).
|
||||
The <function>extractQuery</function> method, instead of returning a key value
|
||||
to be matched exactly, returns a key value that is the lower bound of
|
||||
the range to be searched, and sets the <literal>pmatch</> flag true.
|
||||
The key range is then scanned using the <function>comparePartial</>
|
||||
method. <function>comparePartial</> must return zero for a matching
|
||||
the range to be searched, and sets the <literal>pmatch</literal> flag true.
|
||||
The key range is then scanned using the <function>comparePartial</function>
|
||||
method. <function>comparePartial</function> must return zero for a matching
|
||||
index key, less than zero for a non-match that is still within the range
|
||||
to be searched, or greater than zero if the index key is past the range
|
||||
that could match.
|
||||
@@ -542,7 +542,7 @@
|
||||
<listitem>
|
||||
<para>
|
||||
Build time for a <acronym>GIN</acronym> index is very sensitive to
|
||||
the <varname>maintenance_work_mem</> setting; it doesn't pay to
|
||||
the <varname>maintenance_work_mem</varname> setting; it doesn't pay to
|
||||
skimp on work memory during index creation.
|
||||
</para>
|
||||
</listitem>
|
||||
@@ -553,18 +553,18 @@
|
||||
<listitem>
|
||||
<para>
|
||||
During a series of insertions into an existing <acronym>GIN</acronym>
|
||||
index that has <literal>fastupdate</> enabled, the system will clean up
|
||||
index that has <literal>fastupdate</literal> enabled, the system will clean up
|
||||
the pending-entry list whenever the list grows larger than
|
||||
<varname>gin_pending_list_limit</>. To avoid fluctuations in observed
|
||||
<varname>gin_pending_list_limit</varname>. To avoid fluctuations in observed
|
||||
response time, it's desirable to have pending-list cleanup occur in the
|
||||
background (i.e., via autovacuum). Foreground cleanup operations
|
||||
can be avoided by increasing <varname>gin_pending_list_limit</>
|
||||
can be avoided by increasing <varname>gin_pending_list_limit</varname>
|
||||
or making autovacuum more aggressive.
|
||||
However, enlarging the threshold of the cleanup operation means that
|
||||
if a foreground cleanup does occur, it will take even longer.
|
||||
</para>
|
||||
<para>
|
||||
<varname>gin_pending_list_limit</> can be overridden for individual
|
||||
<varname>gin_pending_list_limit</varname> can be overridden for individual
|
||||
GIN indexes by changing storage parameters, and which allows each
|
||||
GIN index to have its own cleanup threshold.
|
||||
For example, it's possible to increase the threshold only for the GIN
|
||||
@@ -616,7 +616,7 @@
|
||||
|
||||
<para>
|
||||
<acronym>GIN</acronym> assumes that indexable operators are strict. This
|
||||
means that <function>extractValue</> will not be called at all on a null
|
||||
means that <function>extractValue</function> will not be called at all on a null
|
||||
item value (instead, a placeholder index entry is created automatically),
|
||||
and <function>extractQuery</function> will not be called on a null query
|
||||
value either (instead, the query is presumed to be unsatisfiable). Note
|
||||
@@ -629,36 +629,36 @@
|
||||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
The core <productname>PostgreSQL</> distribution
|
||||
The core <productname>PostgreSQL</productname> distribution
|
||||
includes the <acronym>GIN</acronym> operator classes previously shown in
|
||||
<xref linkend="gin-builtin-opclasses-table">.
|
||||
The following <filename>contrib</> modules also contain
|
||||
The following <filename>contrib</filename> modules also contain
|
||||
<acronym>GIN</acronym> operator classes:
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><filename>btree_gin</></term>
|
||||
<term><filename>btree_gin</filename></term>
|
||||
<listitem>
|
||||
<para>B-tree equivalent functionality for several data types</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>hstore</></term>
|
||||
<term><filename>hstore</filename></term>
|
||||
<listitem>
|
||||
<para>Module for storing (key, value) pairs</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>intarray</></term>
|
||||
<term><filename>intarray</filename></term>
|
||||
<listitem>
|
||||
<para>Enhanced support for <type>int[]</type></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><filename>pg_trgm</></term>
|
||||
<term><filename>pg_trgm</filename></term>
|
||||
<listitem>
|
||||
<para>Text similarity using trigram matching</para>
|
||||
</listitem>
|
||||
|
||||
Reference in New Issue
Block a user