Compare commits

...

1 Commits

Author SHA1 Message Date
drh 8afaa1aeec 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.

FossilOrigin-Name: 4cda3b305bd1ca893e40d49d90481f4d403ca50a
2017-01-21 15:30:20 +00:00
3 changed files with 33 additions and 11 deletions
+9 -6
View File
@@ -1,5 +1,5 @@
C Remove\san\sunnecessary\ssqlite3_bind_int64()\scall\sfrom\ssqlite3_blob_open().\nAlso\sother\sminor\srefactoring\sof\sthe\ssqlite3_blob\simplementation.
D 2017-01-21T14:11:28.343
C A\sproof-of-concept\sfor\srunning\ssqlite3_blob_open()\swithout\susing\sOP_Column\nwhen\soperating\son\sa\spure\skey/value\stable.\s\sThis\sdemo\sdoes\snot\sinclude\sany\ncorrupt\sdatabase\schecking.\s\sUses\sabout\s3%\sfewer\sCPU\scycles\son\sa\skey/value\nperformance\stest.
D 2017-01-21T15:30:20.343
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -462,7 +462,7 @@ F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b
F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e
F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24
F src/vdbeaux.c 35c9a9908174e5a26c96d15e1f98214814a39147
F src/vdbeblob.c 824f360105b8cd43c2ec8c4611fd3b162a3a3eed
F src/vdbeblob.c d6e8d827a3c72447b6b5bbde69080f021fb2fc9a
F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
@@ -1547,7 +1547,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 264e5c10d7144910b3223b64546567fa20e4bc65
R 8ac11845f3680b4a63ed584c4ec0c997
P 9d197a532349f4b1caf66bbed70ca46df86cb86f
R 74005762b8c6f4cdf8d383a7684f6381
T *branch * kv-access-opt-demo
T *sym-kv-access-opt-demo *
T -sym-trunk *
U drh
Z e8ceb26091bad5772496cc1502eaca7e
Z 398f1069108acd007f88e9b5a9ec3940
+1 -1
View File
@@ -1 +1 @@
9d197a532349f4b1caf66bbed70ca46df86cb86f
4cda3b305bd1ca893e40d49d90481f4d403ca50a
+23 -4
View File
@@ -72,7 +72,22 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
rc = sqlite3_step(p->pStmt);
if( rc==SQLITE_ROW ){
VdbeCursor *pC = v->apCsr[0];
u32 type = pC->aType[p->iCol];
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"
@@ -81,7 +96,6 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
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);
@@ -311,14 +325,19 @@ int sqlite3_blob_open(
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->isPureKV = (pTab->nCol==2 && pTab->iPKey==0);
pBlob->iCol = iCol;
pBlob->db = db;
sqlite3BtreeLeaveAll(db);