1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-18 05:01:01 +03:00

Add gin_clean_pending_list function to clean up GIN pending list

This function cleans up the pending list of the GIN index by
moving entries in it to the main GIN data structure in bulk.
It returns the number of pages cleaned up from the pending list.

This function is useful, for example, when the pending list
needs to be cleaned up *quickly* to improve the performance of
the search using GIN index. VACUUM can do the same thing, too,
but it may take days to run on a large table.

Jeff Janes,
reviewed by Julien Rouhaud, Jaime Casanova, Alvaro Herrera and me.

Discussion: CAMkU=1x8zFkpfnozXyt40zmR3Ub_kHu58LtRmwHUKRgQss7=iQ@mail.gmail.com
This commit is contained in:
Fujii Masao
2016-01-28 12:57:52 +09:00
parent eaf7b1f643
commit 7f46eaf035
9 changed files with 108 additions and 4 deletions

View File

@@ -18036,9 +18036,16 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<primary>brin_summarize_new_values</primary>
</indexterm>
<indexterm>
<primary>gin_clean_pending_list</primary>
</indexterm>
<para>
<xref linkend="functions-admin-index-table"> shows the functions
available for index maintenance tasks.
These functions cannot be executed during recovery.
Use of these functions is restricted to superusers and the owner
of the given index.
</para>
<table id="functions-admin-index-table">
@@ -18056,6 +18063,13 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<entry><type>integer</type></entry>
<entry>summarize page ranges not already summarized</entry>
</row>
<row>
<entry>
<literal><function>gin_clean_pending_list(<parameter>index</> <type>regclass</>)</function></literal>
</entry>
<entry><type>bigint</type></entry>
<entry>move GIN pending list entries into main index structure</entry>
</row>
</tbody>
</tgroup>
</table>
@@ -18069,6 +18083,18 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
into the index.
</para>
<para>
<function>gin_clean_pending_list</> accepts the OID or name of
a GIN index and cleans up the pending list of the specified GIN index
by moving entries in it to the main GIN data structure in bulk.
It returns the number of pages cleaned up from the pending list.
Note that if the argument is a GIN index built with <literal>fastupdate</>
option disabled, the cleanup does not happen and the return value is 0
because the index doesn't have a pending list.
Please see <xref linkend="gin-fast-update"> and <xref linkend="gin-tips">
for details of the pending list and <literal>fastupdate</> option.
</para>
</sect2>
<sect2 id="functions-admin-genfile">

View File

@@ -734,7 +734,9 @@
from the indexed item). As of <productname>PostgreSQL</productname> 8.4,
<acronym>GIN</> 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 if the pending list becomes larger than
When the table is vacuumed or autoanalyzed, or when
<function>gin_clean_pending_list</function> function is called, or if the
pending list becomes larger than
<xref linkend="guc-gin-pending-list-limit">, the entries are moved to the
main <acronym>GIN</acronym> data structure using the same bulk insert
techniques used during initial index creation. This greatly improves

View File

@@ -362,8 +362,8 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
Turning <literal>fastupdate</> off via <command>ALTER INDEX</> prevents
future insertions from going into the list of pending index entries,
but does not in itself flush previous entries. You might want to
<command>VACUUM</> the table afterward to ensure the pending list is
emptied.
<command>VACUUM</> the table or call <function>gin_clean_pending_list</>
function afterward to ensure the pending list is emptied.
</para>
</note>
</listitem>