/ Check-in [476b1156]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance the Btree object to remember whether or not it is holding an Incrblob cursor. Use this knowledge to improve performance in the common case where it does not.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 476b11563c08c6d9c0abd69e4d865c4edcdd45f5
User & Date: drh 2015-06-25 13:03:10
Context
2015-06-25
15:04
Minor optimization to allocateSpace(). check-in: d007bc33 user: drh tags: trunk
13:03
Enhance the Btree object to remember whether or not it is holding an Incrblob cursor. Use this knowledge to improve performance in the common case where it does not. check-in: 476b1156 user: drh tags: trunk
02:26
Remove a line of code that doesn't do any useful work. check-in: 3ee888be user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

   486    486   */
   487    487   static void invalidateIncrblobCursors(
   488    488     Btree *pBtree,          /* The database file to check */
   489    489     i64 iRow,               /* The rowid that might be changing */
   490    490     int isClearTable        /* True if all rows are being deleted */
   491    491   ){
   492    492     BtCursor *p;
   493         -  BtShared *pBt = pBtree->pBt;
          493  +  if( pBtree->hasIncrblobCur==0 ) return;
   494    494     assert( sqlite3BtreeHoldsMutex(pBtree) );
   495         -  for(p=pBt->pCursor; p; p=p->pNext){
   496         -    if( (p->curFlags & BTCF_Incrblob)!=0
   497         -     && (isClearTable || p->info.nKey==iRow)
   498         -    ){
   499         -      p->eState = CURSOR_INVALID;
          495  +  pBtree->hasIncrblobCur = 0;
          496  +  for(p=pBtree->pBt->pCursor; p; p=p->pNext){
          497  +    if( (p->curFlags & BTCF_Incrblob)!=0 ){
          498  +      pBtree->hasIncrblobCur = 1;
          499  +      if( isClearTable || p->info.nKey==iRow ){
          500  +        p->eState = CURSOR_INVALID;
          501  +      }
   500    502       }
   501    503     }
   502    504   }
   503    505   
   504    506   #else
   505    507     /* Stub function when INCRBLOB is omitted */
   506    508     #define invalidateIncrblobCursors(x,y,z)
................................................................................
  9446   9448   }
  9447   9449   
  9448   9450   /* 
  9449   9451   ** Mark this cursor as an incremental blob cursor.
  9450   9452   */
  9451   9453   void sqlite3BtreeIncrblobCursor(BtCursor *pCur){
  9452   9454     pCur->curFlags |= BTCF_Incrblob;
         9455  +  pCur->pBtree->hasIncrblobCur = 1;
  9453   9456   }
  9454   9457   #endif
  9455   9458   
  9456   9459   /*
  9457   9460   ** Set both the "read version" (single byte at byte offset 18) and 
  9458   9461   ** "write version" (single byte at byte offset 19) fields in the database
  9459   9462   ** header to iVersion.

Changes to src/btreeInt.h.

   349    349   */
   350    350   struct Btree {
   351    351     sqlite3 *db;       /* The database connection holding this btree */
   352    352     BtShared *pBt;     /* Sharable content of this btree */
   353    353     u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */
   354    354     u8 sharable;       /* True if we can share pBt with another db */
   355    355     u8 locked;         /* True if db currently has pBt locked */
          356  +  u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */
   356    357     int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */
   357    358     int nBackup;       /* Number of backup operations reading this btree */
   358    359     u32 iDataVersion;  /* Combines with pBt->pPager->iDataVersion */
   359    360     Btree *pNext;      /* List of other sharable Btrees from the same db */
   360    361     Btree *pPrev;      /* Back pointer of the same list */
   361    362   #ifndef SQLITE_OMIT_SHARED_CACHE
   362    363     BtLock lock;       /* Object used to lock page 1 */