From: drh Date: Wed, 24 Feb 2016 15:43:05 +0000 (+0000) Subject: Identify indexes that complete cover their table. X-Git-Tag: version-3.12.0~151^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcovering-index;p=thirdparty%2Fsqlite.git Identify indexes that complete cover their table. FossilOrigin-Name: 71d488b599cbde817de369efac4412569a55b43d --- diff --git a/manifest b/manifest index 15a208ebd8..b5ca9ab6dd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_BITMASK_TYPE\scompile-time\soption. -D 2016-02-23T16:28:34.108 +C Identify\sindexes\sthat\scomplete\scover\stheir\stable. +D 2016-02-24T15:43:05.820 F Makefile.in 4e90dc1521879022aa9479268a4cd141d1771142 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 28fc4ee02333996d31b3602b39eeb8e609a89ce4 @@ -295,7 +295,7 @@ F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73 F src/btree.c 7bb920c473c277380fcb3e8a8ee28ce1a48e0abc F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5 -F src/build.c 88f185a37d1e087818fd7077d84d65c5babefdb1 +F src/build.c 2c85d62e502e3f41f37049733c25be77780660e2 F src/callback.c 0643b8fb06c95a8977beb201b268210d4b131a22 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c 60e135af364d777a9ab41c97e5e89cd224da6198 @@ -1429,7 +1429,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh a98af506df552f3b3c0d904f94e4cdc4e1a6d598 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P aa9f4c622af191edbeb6a535942944f8c91f5c37 -R 4a575c5637747e2b18640a9618428d3e +P 0064a8c77b2b048c71277d1cfd1ba3975b513b70 +R 5e33894201e325c17491a9fc46b648e7 +T *branch * covering-index +T *sym-covering-index * +T -sym-trunk * U drh -Z c4c6cb390dd2f5f6f2bb80636719a5f7 +Z 47bfdcb1d11cf503d0a7a3e3179c205c diff --git a/manifest.uuid b/manifest.uuid index 561abfe587..4694af3ec7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0064a8c77b2b048c71277d1cfd1ba3975b513b70 \ No newline at end of file +71d488b599cbde817de369efac4412569a55b43d \ No newline at end of file diff --git a/src/build.c b/src/build.c index 13446b790e..18b52bd34b 100644 --- a/src/build.c +++ b/src/build.c @@ -3192,6 +3192,17 @@ Index *sqlite3CreateIndex( }else{ pIndex->aiColumn[i] = XN_ROWID; pIndex->azColl[i] = sqlite3StrBINARY; + /* If this index contains every column of its table, then mark + ** it as a covering index */ + if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){ + pIndex->isCovering = 1; + for(j=0; jnCol; j++){ + if( j==pTab->iPKey ) continue; + if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue; + pIndex->isCovering = 0; + break; + } + } } sqlite3DefaultRowEst(pIndex); if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);