Reduce the CPU used by CREATE INDEX statements by taking better advantage of the fact that keys are inserted in sorted order.

FossilOrigin-Name: 592cdc5d7254be7032aa9c0b03405a74ca060b51
This commit is contained in:
dan 2015-04-01 16:18:00 +00:00
parent 7004f3f6a3
commit b18e60b3e4
4 changed files with 12 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Improve\sperformance\sof\smulti-field\ssorts\swhere\sthe\sfirst\sfield\shas\sa\slow\scardinality.
D 2015-03-30T12:06:26.995
C Reduce\sthe\sCPU\sused\sby\sCREATE\sINDEX\sstatements\sby\staking\sbetter\sadvantage\sof\sthe\sfact\sthat\skeys\sare\sinserted\sin\ssorted\sorder.
D 2015-04-01T16:18:00.779
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -176,7 +176,7 @@ F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
F src/btree.c 4f305e554d7d207375c3e29ab0335bd5a473a125
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72
F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a
F src/build.c 9103f5cd8f4071dc0c44a3312956e53f5b7f52c8
F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
F src/complete.c 198a0066ba60ab06fc00fba1998d870a4d575463
F src/ctime.c 98f89724adc891a1a4c655bee04e33e716e05887
@ -293,7 +293,7 @@ F src/update.c 3c4ecc282accf12d39edb8d524cf089645e55a13
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
F src/util.c 98a7627ca48ad3265b6940915a1d08355eb3fc7e
F src/vacuum.c 9460b9de7b2d4e34b0d374894aa6c8a0632be8ec
F src/vdbe.c bbfede5a8a6908b3ddcd55fdb0b2301288dd4754
F src/vdbe.c a9d916abb1e22355a81b0e72040917ba33c87ed7
F src/vdbe.h 7e538ecf47dccb307ea2d087c3ddc2dd8d70e79d
F src/vdbeInt.h 9cbaa84f53ddd2d09a0cf61a94337a3a035d08a0
F src/vdbeapi.c 583d56b129dd27f12bed518270de9ebe521e6a75
@ -1247,7 +1247,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P b58191e91736b1d978db4127f22867dfe2302f7c
R ce44a3d54ad53a02b61fed80311cecef
P 601e7b6b8e6bfabda03b70f75094c9014e3a3c49
R 151febe3c42a1563a662898adadb6b2d
U dan
Z 8753c6822202b0898d8492105ecdb751
Z 37e9d6c37bda7e19a2c8ebf1573e150d

View File

@ -1 +1 @@
601e7b6b8e6bfabda03b70f75094c9014e3a3c49
592cdc5d7254be7032aa9c0b03405a74ca060b51

View File

@ -2763,7 +2763,8 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
addr2 = sqlite3VdbeCurrentAddr(v);
}
sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
sqlite3VdbeAddOp3(v, OP_Last, iIdx, 0, -1);
sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
sqlite3ReleaseTempReg(pParse, regRecord);
sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);

View File

@ -4480,7 +4480,7 @@ case OP_NullRow: {
break;
}
/* Opcode: Last P1 P2 * * *
/* Opcode: Last P1 P2 P3 * *
**
** The next use of the Rowid or Column or Prev instruction for P1
** will refer to the last entry in the database table or index.
@ -4507,6 +4507,7 @@ case OP_Last: { /* jump */
pC->nullRow = (u8)res;
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
pC->seekResult = pOp->p3;
#ifdef SQLITE_DEBUG
pC->seekOp = OP_Last;
#endif