/ Check-in [4737cadc]
Login

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

Overview
Comment:Performance improvement in the OP_Column opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4737cadc414c5f6d256fcceacb19d80d66a8c8e7
User & Date: drh 2016-05-19 16:58:42
Context
2016-05-19
17:51
Optimization marks in vdbe.c. No logic changes. check-in: cf273741 user: drh tags: trunk
16:58
Performance improvement in the OP_Column opcode. check-in: 4737cadc user: drh tags: trunk
16:21
Add test cases to test some fts3/4 edge case behaviour surrounding the '*' character. check-in: 1f577e1f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2481   2481         ** 3-byte type for each of the maximum of 32768 columns plus three
  2482   2482         ** extra bytes for the header length itself.  32768*3 + 3 = 98307.
  2483   2483         */
  2484   2484         if( offset > 98307 || offset > pC->payloadSize ){
  2485   2485           rc = SQLITE_CORRUPT_BKPT;
  2486   2486           goto abort_due_to_error;
  2487   2487         }
         2488  +    }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/
         2489  +      /* The following goto is an optimization.  It can be omitted and
         2490  +      ** everything will still work.  But OP_Column is measurably faster
         2491  +      ** by skipping the subsequent conditional, which is always true.
         2492  +      */
         2493  +      zData = pC->aRow;
         2494  +      assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */
         2495  +      goto op_column_read_header;
  2488   2496       }
  2489         -
  2490         -    /* The following goto is an optimization.  It can be omitted and
  2491         -    ** everything will still work.  But OP_Column is measurably faster
  2492         -    ** by skipping the subsequent conditional, which is always true.
  2493         -    */
  2494         -    assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */
  2495         -    goto op_column_read_header;
  2496   2497     }
  2497   2498   
  2498   2499     /* Make sure at least the first p2+1 entries of the header have been
  2499   2500     ** parsed and valid information is in aOffset[] and pC->aType[].
  2500   2501     */
  2501   2502     if( pC->nHdrParsed<=p2 ){
  2502   2503       /* If there is more header available for parsing in the record, try
  2503   2504       ** to extract additional fields up through the p2+1-th field 
  2504   2505       */
  2505         -    op_column_read_header:
  2506   2506       if( pC->iHdrOffset<aOffset[0] ){
  2507   2507         /* Make sure zData points to enough of the record to cover the header. */
  2508   2508         if( pC->aRow==0 ){
  2509   2509           memset(&sMem, 0, sizeof(sMem));
  2510   2510           rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
  2511   2511           if( rc!=SQLITE_OK ) goto abort_due_to_error;
  2512   2512           zData = (u8*)sMem.z;
  2513   2513         }else{
  2514   2514           zData = pC->aRow;
  2515   2515         }
  2516   2516     
  2517   2517         /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */
         2518  +    op_column_read_header:
  2518   2519         i = pC->nHdrParsed;
  2519   2520         offset64 = aOffset[i];
  2520   2521         zHdr = zData + pC->iHdrOffset;
  2521   2522         zEndHdr = zData + aOffset[0];
  2522         -      assert( i<=p2 && zHdr<zEndHdr );
  2523   2523         do{
  2524   2524           if( (t = zHdr[0])<0x80 ){
  2525   2525             zHdr++;
  2526   2526             offset64 += sqlite3VdbeOneByteSerialTypeLen(t);
  2527   2527           }else{
  2528   2528             zHdr += sqlite3GetVarint32(zHdr, &t);
  2529   2529             offset64 += sqlite3VdbeSerialTypeLen(t);