aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/spgist/spgdoinsert.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-08-29 09:14:08 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-08-29 09:21:20 +0300
commitc82dedb7a8a953785f24a3b10de376760d60c24c (patch)
treefd8ed66d5fc40431790f971e442c5f16cd9ddaa3 /src/backend/access/spgist/spgdoinsert.c
parent9df55c8c3f0eba77de57006999d5700292fa9d33 (diff)
downloadpostgresql-c82dedb7a8a953785f24a3b10de376760d60c24c.tar.gz
postgresql-c82dedb7a8a953785f24a3b10de376760d60c24c.zip
Optimize SP-GiST insertions.
This includes two micro-optimizations to the tight inner loop in descending the SP-GiST tree: 1. avoid an extra function call to index_getprocinfo when calling user-defined choose function, and 2. avoid a useless palloc+pfree when node labels are not used.
Diffstat (limited to 'src/backend/access/spgist/spgdoinsert.c')
-rw-r--r--src/backend/access/spgist/spgdoinsert.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index b3f8f6a2313..36d05703629 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1861,6 +1861,14 @@ spgdoinsert(Relation index, SpGistState *state,
int leafSize;
SPPageDesc current,
parent;
+ FmgrInfo *procinfo = NULL;
+
+ /*
+ * Look up FmgrInfo of the user-defined choose function once, to save
+ * cycles in the loop below.
+ */
+ if (!isnull)
+ procinfo = index_getprocinfo(index, 1, SPGIST_CHOOSE_PROC);
/*
* Since we don't use index_form_tuple in this AM, we have to make sure
@@ -2007,7 +2015,6 @@ spgdoinsert(Relation index, SpGistState *state,
SpGistInnerTuple innerTuple;
spgChooseIn in;
spgChooseOut out;
- FmgrInfo *procinfo;
/*
* spgAddNode and spgSplitTuple cases will loop back to here to
@@ -2035,7 +2042,6 @@ spgdoinsert(Relation index, SpGistState *state,
if (!isnull)
{
/* use user-defined choose method */
- procinfo = index_getprocinfo(index, 1, SPGIST_CHOOSE_PROC);
FunctionCall2Coll(procinfo,
index->rd_indcollation[0],
PointerGetDatum(&in),