diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-05-24 18:57:57 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-05-24 18:57:57 +0000 |
| commit | 3f4d48802271126b1343289a9d2267ff1ed3788a (patch) | |
| tree | b8c7507719ba240834e28cfbb56e2badff118b7e /src/backend/executor | |
| parent | 2f2d05763d1c55c7998c0d7030659e3db6f60183 (diff) | |
| download | postgresql-3f4d48802271126b1343289a9d2267ff1ed3788a.tar.gz | |
Mark index entries "killed" when they are no longer visible to any
transaction, so as to avoid returning them out of the index AM. Saves
repeated heap_fetch operations on frequently-updated rows. Also detect
queries on unique keys (equality to all columns of a unique index), and
don't bother continuing scan once we have found first match.
Killing is implemented in the btree and hash AMs, but not yet in rtree
or gist, because there isn't an equally convenient place to do it in
those AMs (the outer amgetnext routine can't do it without re-pinning
the index page).
Did some small cleanup on APIs of HeapTupleSatisfies, heap_fetch, and
index_insert to make this a little easier.
Diffstat (limited to 'src/backend/executor')
| -rw-r--r-- | src/backend/executor/execMain.c | 7 | ||||
| -rw-r--r-- | src/backend/executor/execUtils.c | 12 | ||||
| -rw-r--r-- | src/backend/executor/nodeTidscan.c | 9 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 29687a54ba..fa276aaeec 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -27,7 +27,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.163 2002/05/21 22:59:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.164 2002/05/24 18:57:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1489,7 +1489,7 @@ lreplace:; numIndices = resultRelInfo->ri_NumIndices; if (numIndices > 0) - ExecInsertIndexTuples(slot, &(tuple->t_self), estate, true); + ExecInsertIndexTuples(slot, &(tuple->t_self), estate, false); /* AFTER ROW UPDATE Triggers */ if (resultRelInfo->ri_TrigDesc) @@ -1639,8 +1639,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) { Buffer buffer; - heap_fetch(relation, SnapshotDirty, &tuple, &buffer, NULL); - if (tuple.t_data != NULL) + if (heap_fetch(relation, SnapshotDirty, &tuple, &buffer, false, NULL)) { TransactionId xwait = SnapshotDirty->xmax; diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index a6b5048326..32cd88ed07 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.81 2002/05/12 20:10:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.82 2002/05/24 18:57:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -599,7 +599,7 @@ void ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid, EState *estate, - bool is_update) + bool is_vacuum) { HeapTuple heapTuple; ResultRelInfo *resultRelInfo; @@ -667,11 +667,17 @@ ExecInsertIndexTuples(TupleTableSlot *slot, datum, nullv); + /* + * The index AM does the rest. Note we suppress unique-index + * checks if we are being called from VACUUM, since VACUUM may + * need to move dead tuples that have the same keys as live ones. + */ result = index_insert(relationDescs[i], /* index relation */ datum, /* array of heaptuple Datums */ nullv, /* info on nulls */ &(heapTuple->t_self), /* tid of heap tuple */ - heapRelation); + heapRelation, + relationDescs[i]->rd_uniqueindex && !is_vacuum); /* * keep track of index inserts for debugging diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c index 5ee222744d..46e9daed6c 100644 --- a/src/backend/executor/nodeTidscan.c +++ b/src/backend/executor/nodeTidscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.23 2002/02/19 20:11:14 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.24 2002/05/24 18:57:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -150,11 +150,8 @@ TidNext(TidScan *node) { bool slot_is_valid = false; - tuple->t_datamcxt = NULL; - tuple->t_data = NULL; tuple->t_self = tidList[tidstate->tss_TidPtr]; - heap_fetch(heapRelation, snapshot, tuple, &buffer, NULL); - if (tuple->t_data != NULL) + if (heap_fetch(heapRelation, snapshot, tuple, &buffer, false, NULL)) { bool prev_matches = false; int prev_tid; @@ -198,8 +195,6 @@ TidNext(TidScan *node) else ExecClearTuple(slot); } - else if (BufferIsValid(buffer)) - ReleaseBuffer(buffer); tidNumber++; if (bBackward) tidstate->tss_TidPtr--; |
