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

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.
This commit is contained in:
Tom Lane
2002-05-24 18:57:57 +00:00
parent 2f2d05763d
commit 3f4d488022
30 changed files with 498 additions and 273 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: valid.h,v 1.26 2001/11/05 17:46:31 momjian Exp $
* $Id: valid.h,v 1.27 2002/05/24 18:57:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,14 +77,9 @@ do \
/* ----------------
* HeapTupleSatisfies
*
* Returns a valid HeapTuple if it satisfies the timequal and keytest.
* Returns NULL otherwise. Used to be heap_satisifies (sic) which
* returned a boolean. It now returns a tuple so that we can avoid doing two
* PageGetItem's per tuple.
*
* Complete check of validity including LP_CTUP and keytest.
* This should perhaps be combined with valid somehow in the
* future. (Also, additional rule tests/time range tests.)
* res is set TRUE if the HeapTuple satisfies the timequal and keytest,
* otherwise it is set FALSE. Note that the hint bits in the HeapTuple's
* t_infomask may be updated as a side effect.
*
* on 8/21/92 mao says: i rearranged the tests here to do keytest before
* SatisfiesTimeQual. profiling indicated that even for vacuumed relations,
@@ -100,35 +95,28 @@ do \
disk_page, \
seeself, \
nKeys, \
key) \
key, \
res) \
do \
{ \
/* We use underscores to protect the variable passed in as parameters */ \
bool _res; \
\
if ((key) != NULL) \
HeapKeyTest(tuple, RelationGetDescr(relation), \
(nKeys), (key), _res); \
(nKeys), (key), (res)); \
else \
_res = TRUE; \
(res) = true; \
\
if (_res) \
if (res) \
{ \
if ((relation)->rd_rel->relkind != RELKIND_UNCATALOGED) \
{ \
uint16 _infomask = (tuple)->t_data->t_infomask; \
\
_res = HeapTupleSatisfiesVisibility((tuple), (seeself)); \
(res) = HeapTupleSatisfiesVisibility((tuple), (seeself)); \
if ((tuple)->t_data->t_infomask != _infomask) \
SetBufferCommitInfoNeedsSave(buffer); \
if (!_res) \
(tuple)->t_data = NULL; \
} \
} \
else \
{ \
(tuple)->t_data = NULL; \
} \
} while (0)
#endif /* VALID_H */