mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-03 20:17:20 +02:00
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.
62 lines
2.0 KiB
C
62 lines
2.0 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* tidbitmap.h
|
|
* PostgreSQL tuple-id (TID) bitmap package
|
|
*
|
|
* This module provides bitmap data structures that are spiritually
|
|
* similar to Bitmapsets, but are specially adapted to store sets of
|
|
* tuple identifiers (TIDs), or ItemPointers. In particular, the division
|
|
* of an ItemPointer into BlockNumber and OffsetNumber is catered for.
|
|
* Also, since we wish to be able to store very large tuple sets in
|
|
* memory with this data structure, we support "lossy" storage, in which
|
|
* we no longer remember individual tuple offsets on a page but only the
|
|
* fact that a particular page needs to be visited.
|
|
*
|
|
*
|
|
* Copyright (c) 2003-2008, PostgreSQL Global Development Group
|
|
*
|
|
* $PostgreSQL: pgsql/src/include/nodes/tidbitmap.h,v 1.7 2008/04/10 22:25:26 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef TIDBITMAP_H
|
|
#define TIDBITMAP_H
|
|
|
|
#include "storage/itemptr.h"
|
|
|
|
|
|
/*
|
|
* Actual bitmap representation is private to tidbitmap.c. Callers can
|
|
* do IsA(x, TIDBitmap) on it, but nothing else.
|
|
*/
|
|
typedef struct TIDBitmap TIDBitmap;
|
|
|
|
/* Result structure for tbm_iterate */
|
|
typedef struct
|
|
{
|
|
BlockNumber blockno; /* page number containing tuples */
|
|
int ntuples; /* -1 indicates lossy result */
|
|
bool recheck; /* should the tuples be rechecked? */
|
|
/* Note: recheck is always true if ntuples < 0 */
|
|
OffsetNumber offsets[1]; /* VARIABLE LENGTH ARRAY */
|
|
} TBMIterateResult; /* VARIABLE LENGTH STRUCT */
|
|
|
|
/* function prototypes in nodes/tidbitmap.c */
|
|
|
|
extern TIDBitmap *tbm_create(long maxbytes);
|
|
extern void tbm_free(TIDBitmap *tbm);
|
|
|
|
extern void tbm_add_tuples(TIDBitmap *tbm,
|
|
const ItemPointer tids, int ntids,
|
|
bool recheck);
|
|
|
|
extern void tbm_union(TIDBitmap *a, const TIDBitmap *b);
|
|
extern void tbm_intersect(TIDBitmap *a, const TIDBitmap *b);
|
|
|
|
extern bool tbm_is_empty(const TIDBitmap *tbm);
|
|
|
|
extern void tbm_begin_iterate(TIDBitmap *tbm);
|
|
extern TBMIterateResult *tbm_iterate(TIDBitmap *tbm);
|
|
|
|
#endif /* TIDBITMAP_H */
|