mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Replace "amgetmulti" AM functions with "amgetbitmap", in which the whole
indexscan always occurs in one call, and the results are returned in a TIDBitmap instead of a limited-size array of TIDs. This should improve speed a little by reducing AM entry/exit overhead, and it is necessary infrastructure if we are ever to support bitmap indexes. In an only slightly related change, add support for TIDBitmaps to preserve (somewhat lossily) the knowledge that particular TIDs reported by an index need to have their quals rechecked when the heap is visited. This facility is not really used yet; we'll need to extend the forced-recheck feature to plain indexscans before it's useful, and that hasn't been coded yet. The intent is to use it to clean up 8.3's horrid @@@ kluge for text search with weighted queries. There might be other uses in future, but that one alone is sufficient reason. Heikki Linnakangas, with some adjustments by me.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.69 2008/01/01 19:45:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/genam.h,v 1.70 2008/04/10 22:25:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "access/relscan.h"
|
||||
#include "access/sdir.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "nodes/tidbitmap.h"
|
||||
#include "storage/lock.h"
|
||||
|
||||
/*
|
||||
@@ -99,7 +100,7 @@ extern IndexScanDesc index_beginscan(Relation heapRelation,
|
||||
Relation indexRelation,
|
||||
Snapshot snapshot,
|
||||
int nkeys, ScanKey key);
|
||||
extern IndexScanDesc index_beginscan_multi(Relation indexRelation,
|
||||
extern IndexScanDesc index_beginscan_bitmap(Relation indexRelation,
|
||||
Snapshot snapshot,
|
||||
int nkeys, ScanKey key);
|
||||
extern void index_rescan(IndexScanDesc scan, ScanKey key);
|
||||
@@ -109,9 +110,7 @@ extern void index_restrpos(IndexScanDesc scan);
|
||||
extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction);
|
||||
extern bool index_getnext_indexitem(IndexScanDesc scan,
|
||||
ScanDirection direction);
|
||||
extern bool index_getmulti(IndexScanDesc scan,
|
||||
ItemPointer tids, int32 max_tids,
|
||||
int32 *returned_tids);
|
||||
extern int64 index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap);
|
||||
|
||||
extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info,
|
||||
IndexBulkDeleteResult *stats,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (c) 2006-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/gin.h,v 1.16 2008/01/01 19:45:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/gin.h,v 1.17 2008/04/10 22:25:25 tgl Exp $
|
||||
*--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -422,7 +422,7 @@ extern PGDLLIMPORT int GinFuzzySearchLimit;
|
||||
#define ItemPointerSetMin(p) ItemPointerSet( (p), (BlockNumber)0, (OffsetNumber)0)
|
||||
#define ItemPointerIsMin(p) ( ItemPointerGetBlockNumber(p) == (BlockNumber)0 && ItemPointerGetOffsetNumber(p) == (OffsetNumber)0 )
|
||||
|
||||
extern Datum gingetmulti(PG_FUNCTION_ARGS);
|
||||
extern Datum gingetbitmap(PG_FUNCTION_ARGS);
|
||||
extern Datum gingettuple(PG_FUNCTION_ARGS);
|
||||
|
||||
/* ginvacuum.c */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.28 2008/01/01 19:45:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.29 2008/04/10 22:25:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -269,7 +269,7 @@ extern XLogRecPtr gistxlogInsertCompletion(RelFileNode node, ItemPointerData *ke
|
||||
|
||||
/* gistget.c */
|
||||
extern Datum gistgettuple(PG_FUNCTION_ARGS);
|
||||
extern Datum gistgetmulti(PG_FUNCTION_ARGS);
|
||||
extern Datum gistgetbitmap(PG_FUNCTION_ARGS);
|
||||
|
||||
/* gistutil.c */
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/hash.h,v 1.86 2008/03/16 23:15:08 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/hash.h,v 1.87 2008/04/10 22:25:25 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* modeled after Margo Seltzer's hash implementation for unix.
|
||||
@@ -233,7 +233,7 @@ extern Datum hashbuild(PG_FUNCTION_ARGS);
|
||||
extern Datum hashinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum hashbeginscan(PG_FUNCTION_ARGS);
|
||||
extern Datum hashgettuple(PG_FUNCTION_ARGS);
|
||||
extern Datum hashgetmulti(PG_FUNCTION_ARGS);
|
||||
extern Datum hashgetbitmap(PG_FUNCTION_ARGS);
|
||||
extern Datum hashrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum hashendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum hashmarkpos(PG_FUNCTION_ARGS);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.116 2008/01/01 19:45:56 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.117 2008/04/10 22:25:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -507,7 +507,7 @@ extern Datum btbuild(PG_FUNCTION_ARGS);
|
||||
extern Datum btinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum btbeginscan(PG_FUNCTION_ARGS);
|
||||
extern Datum btgettuple(PG_FUNCTION_ARGS);
|
||||
extern Datum btgetmulti(PG_FUNCTION_ARGS);
|
||||
extern Datum btgetbitmap(PG_FUNCTION_ARGS);
|
||||
extern Datum btrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum btendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum btmarkpos(PG_FUNCTION_ARGS);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.61 2008/03/26 16:20:48 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.62 2008/04/10 22:25:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ typedef HeapScanDescData *HeapScanDesc;
|
||||
|
||||
/*
|
||||
* We use the same IndexScanDescData structure for both amgettuple-based
|
||||
* and amgetmulti-based index scans. Some fields are only relevant in
|
||||
* and amgetbitmap-based index scans. Some fields are only relevant in
|
||||
* amgettuple-based scans.
|
||||
*/
|
||||
typedef struct IndexScanDescData
|
||||
@@ -68,7 +68,6 @@ typedef struct IndexScanDescData
|
||||
Snapshot xs_snapshot; /* snapshot to see */
|
||||
int numberOfKeys; /* number of scan keys */
|
||||
ScanKey keyData; /* array of scan key descriptors */
|
||||
bool is_multiscan; /* TRUE = using amgetmulti */
|
||||
|
||||
/* signaling to index AM about killing index tuples */
|
||||
bool kill_prior_tuple; /* last-returned tuple is dead */
|
||||
|
||||
Reference in New Issue
Block a user