1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

Teach SP-GiST to do index-only scans.

Operator classes can specify whether or not they support this; this
preserves the flexibility to use lossy representations within an index.

In passing, move constant data about a given index into the rd_amcache
cache area, instead of doing fresh lookups each time we start an index
operation.  This is mainly to try to make sure that spgcanreturn() has
insignificant cost; I still don't have any proof that it matters for
actual index accesses.  Also, get rid of useless copying of FmgrInfo
pointers; we can perfectly well use the relcache's versions in-place.
This commit is contained in:
Tom Lane
2011-12-19 14:58:41 -05:00
parent 3695a55513
commit 9220362493
10 changed files with 286 additions and 172 deletions

View File

@ -15,6 +15,7 @@
#include "postgres.h"
#include "access/genam.h"
#include "access/spgist_private.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
@ -678,6 +679,7 @@ doPickSplit(Relation index, SpGistState *state,
bool insertedNew = false;
spgPickSplitIn in;
spgPickSplitOut out;
FmgrInfo *procinfo;
bool includeNew;
int i,
max,
@ -816,7 +818,8 @@ doPickSplit(Relation index, SpGistState *state,
*/
memset(&out, 0, sizeof(out));
FunctionCall2Coll(&state->picksplitFn,
procinfo = index_getprocinfo(index, 1, SPGIST_PICKSPLIT_PROC);
FunctionCall2Coll(procinfo,
index->rd_indcollation[0],
PointerGetDatum(&in),
PointerGetDatum(&out));
@ -1944,6 +1947,7 @@ spgdoinsert(Relation index, SpGistState *state,
SpGistInnerTuple innerTuple;
spgChooseIn in;
spgChooseOut out;
FmgrInfo *procinfo;
/*
* spgAddNode and spgSplitTuple cases will loop back to here to
@ -1968,7 +1972,8 @@ spgdoinsert(Relation index, SpGistState *state,
memset(&out, 0, sizeof(out));
FunctionCall2Coll(&state->chooseFn,
procinfo = index_getprocinfo(index, 1, SPGIST_CHOOSE_PROC);
FunctionCall2Coll(procinfo,
index->rd_indcollation[0],
PointerGetDatum(&in),
PointerGetDatum(&out));