mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Minor simplification and performance optimization for Direct Overflow Read.
FossilOrigin-Name: 3e96d6efa867b765c8acf1454014b1e71b2e4f21
This commit is contained in:
24
src/btree.c
24
src/btree.c
@@ -4460,8 +4460,7 @@ static int accessPayload(
|
||||
MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */
|
||||
BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
|
||||
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||
unsigned char * const pBufStart = pBuf;
|
||||
int bEnd; /* True if reading to end of data */
|
||||
unsigned char * const pBufStart = pBuf; /* Start of original out buffer */
|
||||
#endif
|
||||
|
||||
assert( pPage );
|
||||
@@ -4472,9 +4471,6 @@ static int accessPayload(
|
||||
|
||||
getCellInfo(pCur);
|
||||
aPayload = pCur->info.pPayload;
|
||||
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||
bEnd = offset+amt==pCur->info.nPayload;
|
||||
#endif
|
||||
assert( offset+amt <= pCur->info.nPayload );
|
||||
|
||||
assert( aPayload > pPage->aData );
|
||||
@@ -4579,7 +4575,7 @@ static int accessPayload(
|
||||
** range of data that is being read (eOp==0) or written (eOp!=0).
|
||||
*/
|
||||
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
||||
sqlite3_file *fd;
|
||||
sqlite3_file *fd; /* File from which to do direct overflow read */
|
||||
#endif
|
||||
int a = amt;
|
||||
if( a + offset > ovflSize ){
|
||||
@@ -4591,11 +4587,10 @@ static int accessPayload(
|
||||
**
|
||||
** 1) this is a read operation, and
|
||||
** 2) data is required from the start of this overflow page, and
|
||||
** 3) the database is file-backed, and
|
||||
** 4) there is no open write-transaction, and
|
||||
** 3) there is no open write-transaction, and
|
||||
** 4) the database is file-backed, and
|
||||
** 5) the page is not in the WAL file
|
||||
** 6) all data from the page is being read.
|
||||
** 7) at least 4 bytes have already been read into the output buffer
|
||||
** 6) at least 4 bytes have already been read into the output buffer
|
||||
**
|
||||
** then data can be read directly from the database file into the
|
||||
** output buffer, bypassing the page-cache altogether. This speeds
|
||||
@@ -4603,15 +4598,14 @@ static int accessPayload(
|
||||
*/
|
||||
if( (eOp&0x01)==0 /* (1) */
|
||||
&& offset==0 /* (2) */
|
||||
&& (bEnd || a==ovflSize) /* (6) */
|
||||
&& pBt->inTransaction==TRANS_READ /* (4) */
|
||||
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
|
||||
&& pBt->inTransaction==TRANS_READ /* (3) */
|
||||
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (4) */
|
||||
&& 0==sqlite3PagerUseWal(pBt->pPager, nextPage) /* (5) */
|
||||
&& &pBuf[-4]>=pBufStart /* (7) */
|
||||
&& &pBuf[-4]>=pBufStart /* (6) */
|
||||
){
|
||||
u8 aSave[4];
|
||||
u8 *aWrite = &pBuf[-4];
|
||||
assert( aWrite>=pBufStart ); /* hence (7) */
|
||||
assert( aWrite>=pBufStart ); /* due to (6) */
|
||||
memcpy(aSave, aWrite, 4);
|
||||
rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
|
||||
nextPage = get4byte(aWrite);
|
||||
|
Reference in New Issue
Block a user