diff options
| author | Neil Conway | 2005-01-18 23:25:55 +0000 |
|---|---|---|
| committer | Neil Conway | 2005-01-18 23:25:55 +0000 |
| commit | b4297c177c466d2cc0268df6b16261ab4f3cb777 (patch) | |
| tree | bc2f25fcf8ed589ba0fb82d37fc5c76bd9dd14ac /src/include/access | |
| parent | 1f5299bc3fde2e738e7080af72d26a08da53cabd (diff) | |
This patch makes some improvements to the rtree index implementation:
(1) Keep a pin on the scan's current buffer and mark buffer. This
avoids the need to do a ReadBuffer() for each tuple produced by the
scan. Since ReadBuffer() is expensive, this is a significant win.
(2) Convert a ReleaseBuffer(); ReadBuffer() pair into
ReleaseAndReadBuffer(). Surely not a huge win, but it saves a lock
acquire/release...
(3) Remove a bunch of duplicated code in rtget.c; make rtnext() handle
both the "initial result" and "subsequent result" cases.
(4) Add support for index tuple killing
(5) Remove rtscancache(): it is dead code, for the same reason that
gistscancache() is dead code (an index scan ought not be invoked with
NoMovementScanDirection).
The end result is about a 10% improvement in rtree index scan perf,
according to contrib/rtree_gist/bench.
Diffstat (limited to 'src/include/access')
| -rw-r--r-- | src/include/access/rtree.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/include/access/rtree.h b/src/include/access/rtree.h index a5c76855f22..d06ccdcff09 100644 --- a/src/include/access/rtree.h +++ b/src/include/access/rtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/rtree.h,v 1.36 2004/12/31 22:03:21 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/access/rtree.h,v 1.37 2005/01/18 23:25:55 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -59,11 +59,14 @@ typedef struct RTSTACK /* * When we're doing a scan, we need to keep track of the parent stack * for the marked and current items. Also, rtrees have the following - * property: if you're looking for the box (1,1,2,2), on the internal - * nodes you have to search for all boxes that *contain* (1,1,2,2), and - * not the ones that match it. We have a private scan key for internal - * nodes in the opaque structure for rtrees for this reason. See - * access/index-rtree/rtscan.c and rtstrat.c for how it gets initialized. + * property: if you're looking for the box (1,1,2,2), on the internal + * nodes you have to search for all boxes that *contain* (1,1,2,2), + * and not the ones that match it. We have a private scan key for + * internal nodes in the opaque structure for rtrees for this reason. + * See access/index-rtree/rtscan.c and rtstrat.c for how it gets + * initialized. We also keep pins on the scan's current buffer and + * marked buffer, if any: this avoids the need to invoke ReadBuffer() + * for each tuple produced by the index scan. */ typedef struct RTreeScanOpaqueData @@ -73,6 +76,8 @@ typedef struct RTreeScanOpaqueData uint16 s_flags; int s_internalNKey; ScanKey s_internalKey; + Buffer curbuf; + Buffer markbuf; } RTreeScanOpaqueData; typedef RTreeScanOpaqueData *RTreeScanOpaque; |
