mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Fix outdated comments, GIST search queue is not an RBTree anymore.
The GiST search queue is implemented as a pairing heap rather than as Red-Black Tree, since 9.5 (commit e7032610). I neglected these comments in that commit.
This commit is contained in:
parent
40c3fe4980
commit
45310221a9
@ -125,7 +125,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
|
|||||||
* which is created on the second call and reset on later calls. Thus, in
|
* which is created on the second call and reset on later calls. Thus, in
|
||||||
* the common case where a scan is only rescan'd once, we just put the
|
* the common case where a scan is only rescan'd once, we just put the
|
||||||
* queue in scanCxt and don't pay the overhead of making a second memory
|
* queue in scanCxt and don't pay the overhead of making a second memory
|
||||||
* context. If we do rescan more than once, the first RBTree is just left
|
* context. If we do rescan more than once, the first queue is just left
|
||||||
* for dead until end of scan; this small wastage seems worth the savings
|
* for dead until end of scan; this small wastage seems worth the savings
|
||||||
* in the common case.
|
* in the common case.
|
||||||
*/
|
*/
|
||||||
@ -181,7 +181,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
|
|||||||
ALLOCSET_DEFAULT_SIZES);
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create new, empty RBTree for search queue */
|
/* create new, empty pairing heap for search queue */
|
||||||
oldCxt = MemoryContextSwitchTo(so->queueCxt);
|
oldCxt = MemoryContextSwitchTo(so->queueCxt);
|
||||||
so->queue = pairingheap_allocate(pairingheap_GISTSearchItem_cmp, scan);
|
so->queue = pairingheap_allocate(pairingheap_GISTSearchItem_cmp, scan);
|
||||||
MemoryContextSwitchTo(oldCxt);
|
MemoryContextSwitchTo(oldCxt);
|
||||||
|
@ -107,15 +107,11 @@ typedef struct GISTSTATE
|
|||||||
* upper index pages; this rule avoids doing extra work during a search that
|
* upper index pages; this rule avoids doing extra work during a search that
|
||||||
* ends early due to LIMIT.
|
* ends early due to LIMIT.
|
||||||
*
|
*
|
||||||
* To perform an ordered search, we use an RBTree to manage the distance-order
|
* To perform an ordered search, we use a pairing heap to manage the
|
||||||
* queue. Each GISTSearchTreeItem stores all unvisited items of the same
|
* distance-order queue. In a non-ordered search (no order-by operators),
|
||||||
* distance; they are GISTSearchItems chained together via their next fields.
|
* we use it to return heap tuples before unvisited index pages, to
|
||||||
*
|
* ensure depth-first order, but all entries are otherwise considered
|
||||||
* In a non-ordered search (no order-by operators), the RBTree degenerates
|
* equal.
|
||||||
* to a single item, which we use as a queue of unvisited index pages only.
|
|
||||||
* In this case matched heap items from the current index leaf page are
|
|
||||||
* remembered in GISTScanOpaqueData.pageData[] and returned directly from
|
|
||||||
* there, instead of building a separate GISTSearchItem for each one.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Individual heap tuple to be visited */
|
/* Individual heap tuple to be visited */
|
||||||
@ -298,8 +294,8 @@ typedef struct
|
|||||||
#define GIST_ROOT_BLKNO 0
|
#define GIST_ROOT_BLKNO 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before PostgreSQL 9.1, we used rely on so-called "invalid tuples" on inner
|
* Before PostgreSQL 9.1, we used to rely on so-called "invalid tuples" on
|
||||||
* pages to finish crash recovery of incomplete page splits. If a crash
|
* inner pages to finish crash recovery of incomplete page splits. If a crash
|
||||||
* happened in the middle of a page split, so that the downlink pointers were
|
* happened in the middle of a page split, so that the downlink pointers were
|
||||||
* not yet inserted, crash recovery inserted a special downlink pointer. The
|
* not yet inserted, crash recovery inserted a special downlink pointer. The
|
||||||
* semantics of an invalid tuple was that it if you encounter one in a scan,
|
* semantics of an invalid tuple was that it if you encounter one in a scan,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user