/ Check-in [2cf3f3de]
Login

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

Overview
Comment:Small size and performance improvement in the OP_Column opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2cf3f3de8a48465bd6b0af7763bfe905f3bb0151488f63c9ecc3147bcb345094
User & Date: drh 2017-08-15 14:14:36
Original Comment: Small size and performance in the OP_Column opcode.
Context
2017-08-16
11:04
Performance improvement in the OP_Column opcode. check-in: dc98a92f user: drh tags: trunk
2017-08-15
14:14
Small size and performance improvement in the OP_Column opcode. check-in: 2cf3f3de user: drh tags: trunk
03:46
Btree optimization: New field BtCursor.pPage that points to the current page, saving a single pointer dereference on each access. check-in: 373b71d1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2384   2384     Mem *pDest;        /* Where to write the extracted value */
  2385   2385     Mem sMem;          /* For storing the record being decoded */
  2386   2386     const u8 *zData;   /* Part of the record being decoded */
  2387   2387     const u8 *zHdr;    /* Next unparsed byte of the header */
  2388   2388     const u8 *zEndHdr; /* Pointer to first byte after the header */
  2389   2389     u32 offset;        /* Offset into the data */
  2390   2390     u64 offset64;      /* 64-bit offset */
  2391         -  u32 avail;         /* Number of bytes of available data */
  2392   2391     u32 t;             /* A type code from the record header */
  2393   2392     Mem *pReg;         /* PseudoTable input register */
  2394   2393   
  2395   2394     pC = p->apCsr[pOp->p1];
  2396   2395     p2 = pOp->p2;
  2397   2396   
  2398   2397     /* If the cursor cache is stale (meaning it is not currently point at
................................................................................
  2415   2414     if( pC->cacheStatus!=p->cacheCtr ){                /*OPTIMIZATION-IF-FALSE*/
  2416   2415       if( pC->nullRow ){
  2417   2416         if( pC->eCurType==CURTYPE_PSEUDO ){
  2418   2417           assert( pC->uc.pseudoTableReg>0 );
  2419   2418           pReg = &aMem[pC->uc.pseudoTableReg];
  2420   2419           assert( pReg->flags & MEM_Blob );
  2421   2420           assert( memIsValid(pReg) );
  2422         -        pC->payloadSize = pC->szRow = avail = pReg->n;
         2421  +        pC->payloadSize = pC->szRow = pReg->n;
  2423   2422           pC->aRow = (u8*)pReg->z;
  2424   2423         }else{
  2425   2424           sqlite3VdbeMemSetNull(pDest);
  2426   2425           goto op_column_out;
  2427   2426         }
  2428   2427       }else{
  2429   2428         pCrsr = pC->uc.pCursor;
  2430   2429         assert( pC->eCurType==CURTYPE_BTREE );
  2431   2430         assert( pCrsr );
  2432   2431         assert( sqlite3BtreeCursorIsValid(pCrsr) );
  2433   2432         pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
  2434         -      pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
  2435         -      assert( avail<=65536 );  /* Maximum page size is 64KiB */
  2436         -      if( pC->payloadSize <= (u32)avail ){
  2437         -        pC->szRow = pC->payloadSize;
  2438         -      }else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
         2433  +      pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);
         2434  +      assert( pC->szRow<=pC->payloadSize );
         2435  +      assert( pC->szRow<=65536 );  /* Maximum page size is 64KiB */
         2436  +      if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){
  2439   2437           goto too_big;
  2440         -      }else{
  2441         -        pC->szRow = avail;
  2442   2438         }
  2443   2439       }
  2444   2440       pC->cacheStatus = p->cacheCtr;
  2445   2441       pC->iHdrOffset = getVarint32(pC->aRow, offset);
  2446   2442       pC->nHdrParsed = 0;
  2447   2443       aOffset[0] = offset;
  2448   2444   
  2449   2445   
  2450         -    if( avail<offset ){      /*OPTIMIZATION-IF-FALSE*/
         2446  +    if( pC->szRow<offset ){      /*OPTIMIZATION-IF-FALSE*/
  2451   2447         /* pC->aRow does not have to hold the entire row, but it does at least
  2452   2448         ** need to cover the header of the record.  If pC->aRow does not contain
  2453   2449         ** the complete header, then set it to zero, forcing the header to be
  2454   2450         ** dynamically allocated. */
  2455   2451         pC->aRow = 0;
  2456   2452         pC->szRow = 0;
  2457   2453