diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2023-11-25 20:27:04 +0100 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2023-11-25 20:27:28 +0100 |
commit | c1ec02be1d79eac95160dea7ced32ace84664617 (patch) | |
tree | e0038d6d074d5c9f28f397ec6bf6e4c743c4fe43 /doc/src | |
parent | 6ec8262a02a84470a6a5c936e51f6cb641cebce1 (diff) | |
download | postgresql-c1ec02be1d79eac95160dea7ced32ace84664617.tar.gz postgresql-c1ec02be1d79eac95160dea7ced32ace84664617.zip |
Reuse BrinDesc and BrinRevmap in brininsert
The brininsert code used to initialize (and destroy) BrinDesc and
BrinRevmap for each tuple, which is not free. This patch initializes
these structures only once, and reuses them for all inserts in the same
command. The data is passed through indexInfo->ii_AmCache.
This also introduces an optional AM callback "aminsertcleanup" that
allows performing custom cleanup in case simply pfree-ing ii_AmCache is
not sufficient (which is the case when the cache contains TupleDesc,
Buffers, and so on).
Author: Soumyadeep Chakraborty
Reviewed-by: Alvaro Herrera, Matthias van de Meent, Tomas Vondra
Discussion: https://postgr.es/m/CAE-ML%2B9r2%3DaO1wwji1sBN9gvPz2xRAtFUGfnffpd0ZqyuzjamA%40mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/indexam.sgml | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 30eda37afa8..f107c43d6a6 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -139,6 +139,7 @@ typedef struct IndexAmRoutine ambuild_function ambuild; ambuildempty_function ambuildempty; aminsert_function aminsert; + aminsertcleanup_function aminsertcleanup; ambulkdelete_function ambulkdelete; amvacuumcleanup_function amvacuumcleanup; amcanreturn_function amcanreturn; /* can be NULL */ @@ -359,7 +360,21 @@ aminsert (Relation indexRelation, within an SQL statement, it can allocate space in <literal>indexInfo->ii_Context</literal> and store a pointer to the data in <literal>indexInfo->ii_AmCache</literal> (which will be NULL - initially). + initially). After the index insertions complete, the memory will be freed + automatically. If additional cleanup is required (e.g. if the cache contains + buffers and tuple descriptors), the AM may define an optional function + <literal>indexinsertcleanup</literal>, called before the memory is released. + </para> + + <para> +<programlisting> +void +aminsertcleanup (IndexInfo *indexInfo); +</programlisting> + Clean up state that was maintained across successive inserts in + <literal>indexInfo->ii_AmCache</literal>. This is useful if the data + requires additional cleanup steps, and simply releasing the memory is not + sufficient. </para> <para> |