/ Check-in [a9498407]
Login

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

Overview
Comment:Small performance increase and size reduction in the OP_Column opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a9498407e646305e7b60115d63e85c642bbd1c3f
User & Date: drh 2016-11-25 17:03:03
Context
2016-11-25
19:18
Refactor the sqlite3BtreeKey() and sqlite3BtreeData() internal interfaces into sqlite3BtreePayload() and sqlite3BtreePayloadChecked(), respectively. This is a continuation of the optimization started by check-in [2d831074cf]. The result is a slightly smaller and faster binary. check-in: 49ebc219 user: drh tags: trunk
17:03
Small performance increase and size reduction in the OP_Column opcode. check-in: a9498407 user: drh tags: trunk
15:47
Performance enhancement to sqlite3_snprintf(). check-in: c53dca7f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2466   2466     assert( pOp->p1>=0 && pOp->p1<p->nCursor );
  2467   2467     assert( pC!=0 );
  2468   2468     assert( p2<pC->nField );
  2469   2469     aOffset = pC->aOffset;
  2470   2470     assert( pC->eCurType!=CURTYPE_VTAB );
  2471   2471     assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
  2472   2472     assert( pC->eCurType!=CURTYPE_SORTER );
  2473         -  pCrsr = pC->uc.pCursor;
  2474   2473   
  2475   2474     if( pC->cacheStatus!=p->cacheCtr ){                /*OPTIMIZATION-IF-FALSE*/
  2476   2475       if( pC->nullRow ){
  2477   2476         if( pC->eCurType==CURTYPE_PSEUDO ){
  2478   2477           assert( pC->uc.pseudoTableReg>0 );
  2479   2478           pReg = &aMem[pC->uc.pseudoTableReg];
  2480   2479           assert( pReg->flags & MEM_Blob );
................................................................................
  2482   2481           pC->payloadSize = pC->szRow = avail = pReg->n;
  2483   2482           pC->aRow = (u8*)pReg->z;
  2484   2483         }else{
  2485   2484           sqlite3VdbeMemSetNull(pDest);
  2486   2485           goto op_column_out;
  2487   2486         }
  2488   2487       }else{
         2488  +      pCrsr = pC->uc.pCursor;
  2489   2489         assert( pC->eCurType==CURTYPE_BTREE );
  2490   2490         assert( pCrsr );
  2491   2491         assert( sqlite3BtreeCursorIsValid(pCrsr) );
  2492   2492         pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);
  2493   2493         pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail);
  2494   2494         assert( avail<=65536 );  /* Maximum page size is 64KiB */
  2495   2495         if( pC->payloadSize <= (u32)avail ){
................................................................................
  2545   2545       /* If there is more header available for parsing in the record, try
  2546   2546       ** to extract additional fields up through the p2+1-th field 
  2547   2547       */
  2548   2548       if( pC->iHdrOffset<aOffset[0] ){
  2549   2549         /* Make sure zData points to enough of the record to cover the header. */
  2550   2550         if( pC->aRow==0 ){
  2551   2551           memset(&sMem, 0, sizeof(sMem));
  2552         -        rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
         2552  +        rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0],
         2553  +                                     !pC->isTable, &sMem);
  2553   2554           if( rc!=SQLITE_OK ) goto abort_due_to_error;
  2554   2555           zData = (u8*)sMem.z;
  2555   2556         }else{
  2556   2557           zData = pC->aRow;
  2557   2558         }
  2558   2559     
  2559   2560         /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
................................................................................
  2658   2659         **    2. the length(X) function if X is a blob, and
  2659   2660         **    3. if the content length is zero.
  2660   2661         ** So we might as well use bogus content rather than reading
  2661   2662         ** content from disk. */
  2662   2663         static u8 aZero[8];  /* This is the bogus content */
  2663   2664         sqlite3VdbeSerialGet(aZero, t, pDest);
  2664   2665       }else{
  2665         -      rc = sqlite3VdbeMemFromBtree(pCrsr, aOffset[p2], len, !pC->isTable,
  2666         -                                   pDest);
         2666  +      rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len,
         2667  +                                   !pC->isTable, pDest);
  2667   2668         if( rc!=SQLITE_OK ) goto abort_due_to_error;
  2668   2669         sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
  2669   2670         pDest->flags &= ~MEM_Ephem;
  2670   2671       }
  2671   2672     }
  2672   2673   
  2673   2674   op_column_out: