diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-10-09 00:21:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-10-09 00:21:08 -0400 |
commit | cbfa92c23c3924d53889320cdbe26f23ee23e40c (patch) | |
tree | f93756a2e9f1d7e6cbf468b16528f275c04f04e5 /src/backend/access/index | |
parent | 45401c1c25fe1ef14bf68089de86bcb5cce9f453 (diff) | |
download | postgresql-cbfa92c23c3924d53889320cdbe26f23ee23e40c.tar.gz postgresql-cbfa92c23c3924d53889320cdbe26f23ee23e40c.zip |
Improve index-only scans to avoid repeated access to the index page.
We copy all the matched tuples off the page during _bt_readpage, instead of
expensively re-locking the page during each subsequent tuple fetch. This
costs a bit more local storage, but not more than 2*BLCKSZ worth, and the
reduction in LWLock traffic is certainly worth that. What's more, this
lets us get rid of the API wart in the original patch that said an index AM
could randomly decline to supply an index tuple despite having asserted
pg_am.amcanreturn. That will be important for future improvements in the
index-only-scan feature, since the executor will now be able to rely on
having the index data available.
Diffstat (limited to 'src/backend/access/index')
-rw-r--r-- | src/backend/access/index/indexam.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 3e0797a5c2e..6d423a7d682 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -443,9 +443,10 @@ index_getnext_tid(IndexScanDesc scan, ScanDirection direction) Assert(TransactionIdIsValid(RecentGlobalXmin)); /* - * The AM's gettuple proc finds the next index entry matching the scan - * keys, and puts the TID in xs_ctup.t_self. It should also set - * scan->xs_recheck, though we pay no attention to that here. + * The AM's amgettuple proc finds the next index entry matching the scan + * keys, and puts the TID into scan->xs_ctup.t_self. It should also set + * scan->xs_recheck and possibly scan->xs_itup, though we pay no attention + * to those fields here. */ found = DatumGetBool(FunctionCall2(procedure, PointerGetDatum(scan), |