Skip to content

Commit 38cb364

Browse files
authored
Merge pull request #773 from dolthub/perf/restore-cache-on-fastpath
Restore eager payload cache on the no-mutmap Next fast-path
2 parents 9099d3a + 063a30b commit 38cb364

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/prolly_btree.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5257,6 +5257,23 @@ static int prollyBtCursorNext(BtCursor *pCur, int flags){
52575257
if( rc==SQLITE_OK ){
52585258
if( pCur->pCur.eState==PROLLY_CURSOR_VALID ){
52595259
pCur->eState = CURSOR_VALID;
5260+
/* Pre-populate the payload cache for INTKEY clean-read scans
5261+
** (same idea as PR #770, restored on Tim's no-mutmap fast
5262+
** path). xPayloadSize then xPayloadFetch are both called per
5263+
** row during OP_Column / table scans; both go through
5264+
** getCursorPayload's multi-branch chain. Caching the
5265+
** (pData, nData) pair here makes both subsequent trips hit
5266+
** the early-return at the top of getCursorPayload. The
5267+
** pointer borrows the leaf node memory; CLEAR_CACHED_PAYLOAD
5268+
** on the next move keeps it valid for exactly one row. */
5269+
if( pCur->curIntKey ){
5270+
const u8 *pVal; int nVal;
5271+
cursorCurrentTreeValue(pCur, &pVal, &nVal);
5272+
if( nVal > 0 ){
5273+
pCur->pCachedPayload = (u8*)pVal;
5274+
pCur->nCachedPayload = nVal;
5275+
}
5276+
}
52605277
} else {
52615278
pCur->eState = CURSOR_INVALID;
52625279
return SQLITE_DONE;

0 commit comments

Comments
 (0)