From 4e82a954764af0b03c54cd4db422a6b4e585e4e8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 10 Apr 2008 22:25:26 +0000 Subject: 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. --- doc/src/sgml/catalogs.sgml | 6 +++--- doc/src/sgml/indexam.sgml | 49 ++++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 33 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 4c92c2c77a5..a6aaa4fd5a8 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -473,10 +473,10 @@ - amgetmulti + amgetbitmap regproc pg_proc.oid - Fetch multiple tuples function + Fetch all valid tuples function diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml index 8b246719ccf..65da721de47 100644 --- a/doc/src/sgml/indexam.sgml +++ b/doc/src/sgml/indexam.sgml @@ -1,4 +1,4 @@ - + Index Access Method Interface Definition @@ -320,23 +320,16 @@ amgettuple (IndexScanDesc scan, -boolean -amgetmulti (IndexScanDesc scan, - ItemPointer tids, - int32 max_tids, - int32 *returned_tids); +int64 +amgetbitmap (IndexScanDesc scan, + TIDBitmap *tbm); - Fetch multiple tuples in the given scan. Returns TRUE if the scan should - continue, FALSE if no matching tuples remain. tids points to - a caller-supplied array of max_tids - ItemPointerData records, which the call fills with TIDs of - matching tuples. *returned_tids is set to the number of TIDs - actually returned. This can be less than max_tids, or even - zero, even when the return value is TRUE. (This provision allows the - access method to choose the most efficient stopping points in its scan, - for example index page boundaries.) amgetmulti and + Fetch all tuples in the given scan and add them to the caller-supplied + TIDBitmap (that is, OR the set of tuple IDs into whatever set is already + in the bitmap). The number of tuples fetched is returned. + amgetbitmap and amgettuple cannot be used in the same index scan; there - are other restrictions too when using amgetmulti, as explained + are other restrictions too when using amgetbitmap, as explained in . @@ -491,20 +484,17 @@ amrestrpos (IndexScanDesc scan); Instead of using amgettuple, an index scan can be done with - amgetmulti to fetch multiple tuples per call. This can be + amgetbitmap to fetch all tuples in one call. This can be noticeably more efficient than amgettuple because it allows avoiding lock/unlock cycles within the access method. In principle - amgetmulti should have the same effects as repeated + amgetbitmap should have the same effects as repeated amgettuple calls, but we impose several restrictions to - simplify matters. In the first place, amgetmulti does not - take a direction argument, and therefore it does not support - backwards scan nor intrascan reversal of direction. The access method - need not support marking or restoring scan positions during an - amgetmulti scan, either. (These restrictions cost little - since it would be difficult to use these features in an - amgetmulti scan anyway: adjusting the caller's buffered - list of TIDs would be complex.) Finally, amgetmulti does - not guarantee any locking of the returned tuples, with implications + simplify matters. First of all, amgetbitmap returns all + tuples at once and marking or restoring scan positions isn't + supported. Secondly, the tuples are returned in a bitmap which doesn't + have any specific ordering, which is why amgetbitmap doesn't + take a direction argument. Finally, amgetbitmap + does not guarantee any locking of the returned tuples, with implications spelled out in . @@ -605,9 +595,8 @@ amrestrpos (IndexScanDesc scan); - In an amgetmulti index scan, the access method need not - guarantee to keep an index pin on any of the returned tuples. (It would be - impractical to pin more than the last one anyway.) Therefore + In an amgetbitmap index scan, the access method does not + keep an index pin on any of the returned tuples. Therefore it is only safe to use such scans with MVCC-compliant snapshots. -- cgit v1.2.3