mirror of
https://github.com/postgres/postgres.git
synced 2025-12-06 00:02:13 +03:00
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
This commit is contained in:
@@ -113,6 +113,9 @@ typedef bool (*aminsert_function) (Relation indexRelation,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
|
||||
/* cleanup after insert */
|
||||
typedef void (*aminsertcleanup_function) (struct IndexInfo *indexInfo);
|
||||
|
||||
/* bulk delete */
|
||||
typedef IndexBulkDeleteResult *(*ambulkdelete_function) (IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats,
|
||||
@@ -261,6 +264,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 */
|
||||
|
||||
@@ -96,6 +96,7 @@ extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern void brininsertcleanup(struct IndexInfo *indexInfo);
|
||||
extern IndexScanDesc brinbeginscan(Relation r, int nkeys, int norderbys);
|
||||
extern int64 bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
|
||||
extern void brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
||||
|
||||
@@ -148,6 +148,8 @@ extern bool index_insert(Relation indexRelation,
|
||||
IndexUniqueCheck checkUnique,
|
||||
bool indexUnchanged,
|
||||
struct IndexInfo *indexInfo);
|
||||
extern void index_insert_cleanup(Relation indexRelation,
|
||||
struct IndexInfo *indexInfo);
|
||||
|
||||
extern IndexScanDesc index_beginscan(Relation heapRelation,
|
||||
Relation indexRelation,
|
||||
|
||||
Reference in New Issue
Block a user