/ Changes On Branch kv-access-opt-demo
Login

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

Changes In Branch kv-access-opt-demo Excluding Merge-Ins

This is equivalent to a diff from 9d197a5323 to 4cda3b305b

2017-01-21
15:55
In the kvtest.c test utility, reuse the buffer into which blobs are read, rather than reallocating it for each row. This is a closer match to how other test programs work, and thus provides a better comparison. (check-in: 0d1ad13a29 user: drh tags: trunk)
15:30
A proof-of-concept for running sqlite3_blob_open() without using OP_Column when operating on a pure key/value table. This demo does not include any corrupt database checking. Uses about 3% fewer CPU cycles on a key/value performance test. (Leaf check-in: 4cda3b305b user: drh tags: kv-access-opt-demo)
14:11
Remove an unnecessary sqlite3_bind_int64() call from sqlite3_blob_open(). Also other minor refactoring of the sqlite3_blob implementation. (check-in: 9d197a5323 user: drh tags: trunk)
2017-01-20
20:43
Minor performance optimization and size reduction to the accessPayload() routine in btree.c. (check-in: 264e5c10d7 user: drh tags: trunk)

Changes to src/vdbeblob.c.

68
69
70
71
72
73
74













75


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  ** have been down with an extra OP_Goto, but simply setting the program
  ** counter is faster. */
  if( v->pc>3 ) v->pc = 3;

  rc = sqlite3_step(p->pStmt);
  if( rc==SQLITE_ROW ){
    VdbeCursor *pC = v->apCsr[0];













    u32 type = pC->aType[p->iCol];


    if( type<12 ){
      zErr = sqlite3MPrintf(p->db, "cannot open value of type %s",
          type==0?"null": type==7?"real": "integer"
      );
      rc = SQLITE_ERROR;
      sqlite3_finalize(p->pStmt);
      p->pStmt = 0;
    }else{
      p->iOffset = pC->aType[p->iCol + pC->nField];
      p->nByte = sqlite3VdbeSerialTypeLen(type);
      p->pCsr =  pC->uc.pCursor;
      sqlite3BtreeIncrblobCursor(p->pCsr);
    }
  }

  if( rc==SQLITE_ROW ){







>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>








<







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
  ** have been down with an extra OP_Goto, but simply setting the program
  ** counter is faster. */
  if( v->pc>3 ) v->pc = 3;

  rc = sqlite3_step(p->pStmt);
  if( rc==SQLITE_ROW ){
    VdbeCursor *pC = v->apCsr[0];
    u32 type;
    if( p->isPureKV ){
      u32 avail;
      const u8 *a;
      BtCursor *pCrsr = pC->uc.pCursor;
      sqlite3BtreeEnterCursor(pCrsr);
      (void)sqlite3BtreePayloadSize(pCrsr);
      a = (const u8*)sqlite3BtreePayloadFetch(pCrsr, &avail);
      assert( p->iCol==1 );
      getVarint32(a+2, type);
      sqlite3BtreeLeaveCursor(pCrsr);
      p->iOffset = a[0];
    }else{
      type = pC->aType[p->iCol];
      p->iOffset = pC->aType[p->iCol + pC->nField];
    }
    if( type<12 ){
      zErr = sqlite3MPrintf(p->db, "cannot open value of type %s",
          type==0?"null": type==7?"real": "integer"
      );
      rc = SQLITE_ERROR;
      sqlite3_finalize(p->pStmt);
      p->pStmt = 0;
    }else{

      p->nByte = sqlite3VdbeSerialTypeLen(type);
      p->pCsr =  pC->uc.pCursor;
      sqlite3BtreeIncrblobCursor(p->pCsr);
    }
  }

  if( rc==SQLITE_ROW ){
307
308
309
310
311
312
313






314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
        ** we can invoke OP_Column to fill in the vdbe cursors type 
        ** and offset cache without causing any IO.
        */
        aOp[1].p4type = P4_INT32;
        aOp[1].p4.i = pTab->nCol+1;
        aOp[3].p2 = pTab->nCol;







        pParse->nVar = 0;
        pParse->nMem = 1;
        pParse->nTab = 1;
        sqlite3VdbeMakeReady(v, pParse);
      }
    }
   
    pBlob->isPureKV = (pTab->nCol==2 && pTab->iPKey==0);
    pBlob->iCol = iCol;
    pBlob->db = db;
    sqlite3BtreeLeaveAll(db);
    if( db->mallocFailed ){
      goto blob_open_out;
    }
    rc = blobSeekToRow(pBlob, iRow, &zErr);







>
>
>
>
>
>






|
<







321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340

341
342
343
344
345
346
347
        ** we can invoke OP_Column to fill in the vdbe cursors type 
        ** and offset cache without causing any IO.
        */
        aOp[1].p4type = P4_INT32;
        aOp[1].p4.i = pTab->nCol+1;
        aOp[3].p2 = pTab->nCol;

   
        if( pTab->nCol==2 && pTab->iPKey==0 && iCol==1 ){
          pBlob->isPureKV = 1;
          aOp[3].opcode = OP_Noop;
        }

        pParse->nVar = 0;
        pParse->nMem = 1;
        pParse->nTab = 1;
        sqlite3VdbeMakeReady(v, pParse);
      }
    }
      

    pBlob->iCol = iCol;
    pBlob->db = db;
    sqlite3BtreeLeaveAll(db);
    if( db->mallocFailed ){
      goto blob_open_out;
    }
    rc = blobSeekToRow(pBlob, iRow, &zErr);