diff options
author | drh <drh@noemail.net> | 2014-03-04 04:12:56 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-03-04 04:12:56 +0000 |
commit | d34ab07507de47f6ec6c5f8e39a68f01aff4dce8 (patch) | |
tree | fd609b74427efc26463c2f27d624cc695bb6d01a /src/btree.c | |
parent | 6295524e3ddfbcb77bd7a4eed20702c5443464d3 (diff) | |
parent | f926d1ea47939fe1c60d04bcf269b4ad6c1f50a1 (diff) | |
download | sqlite-d34ab07507de47f6ec6c5f8e39a68f01aff4dce8.tar.gz sqlite-d34ab07507de47f6ec6c5f8e39a68f01aff4dce8.zip |
Refactor the sqlite3VdbeRecordCompare() routine used to compare btree records.
Create fast-track special case routines to handle the common cases more
quickly. This gives a significant performance boost.
FossilOrigin-Name: 3325ad5bdc2f81f63b556d6f4d0589d89b142b2b
Diffstat (limited to 'src/btree.c')
-rw-r--r-- | src/btree.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/btree.c b/src/btree.c index 4fd8e27bf..ce35afbd5 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4547,6 +4547,7 @@ int sqlite3BtreeMovetoUnpacked( int *pRes /* Write search results here */ ){ int rc; + RecordCompare xRecordCompare; assert( cursorHoldsMutex(pCur) ); assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); @@ -4568,6 +4569,16 @@ int sqlite3BtreeMovetoUnpacked( } } + if( pIdxKey ){ + xRecordCompare = sqlite3VdbeFindCompare(pIdxKey); + assert( pIdxKey->default_rc==1 + || pIdxKey->default_rc==0 + || pIdxKey->default_rc==-1 + ); + }else{ + xRecordCompare = 0; /* Not actually used. Avoids a compiler warning. */ + } + rc = moveToRoot(pCur); if( rc ){ return rc; @@ -4652,14 +4663,14 @@ int sqlite3BtreeMovetoUnpacked( ** single byte varint and the record fits entirely on the main ** b-tree page. */ testcase( pCell+nCell+1==pPage->aDataEnd ); - c = sqlite3VdbeRecordCompare(nCell, (void*)&pCell[1], pIdxKey); + c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey, 0); }else if( !(pCell[1] & 0x80) && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal ){ /* The record-size field is a 2 byte varint and the record ** fits entirely on the main b-tree page. */ testcase( pCell+nCell+2==pPage->aDataEnd ); - c = sqlite3VdbeRecordCompare(nCell, (void*)&pCell[2], pIdxKey); + c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey, 0); }else{ /* The record flows over onto one or more overflow pages. In ** this case the whole cell needs to be parsed, a buffer allocated @@ -4680,7 +4691,7 @@ int sqlite3BtreeMovetoUnpacked( sqlite3_free(pCellKey); goto moveto_finish; } - c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); + c = xRecordCompare(nCell, pCellKey, pIdxKey, 0); sqlite3_free(pCellKey); } if( c<0 ){ |