diff --git a/manifest b/manifest index b9a5567dec..f40775b78c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sassert()\sfrom\sthe\sOP_SeekScan\sopcode. -D 2020-10-02T12:49:06.118 +C Additional\scorner-case\sfixes\sfor\sthe\sin-scan-vs-index\sor\sOP_SeekScan\noptimization. +D 2020-10-02T13:48:57.472 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -624,9 +624,9 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/wal.c 69e770e96fd56cc21608992bf2c6f1f3dc5cf2572d0495c6a643b06c3a679f14 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a F src/walker.c 3df26a33dc4f54e8771600fb7fdebe1ece0896c2ad68c30ab40b017aa4395049 -F src/where.c da9c0d503f81cc8444eb3525b75eec2bb3d198f4d5939b207977f2fc20d85b54 +F src/where.c 5f4c1467ef425065377ca51d2e3c20b2a90a108f22f21ae1712996f02c6cdc06 F src/whereInt.h 59077fbd0b3d01bc8715e746c86a99ebf4c85bde8a57077ec04d2a23e59666ec -F src/wherecode.c 1a229b9d1f7dd306ee3e82e629caaf424f7ba2f67b045f944c0b0a064ea3c59f +F src/wherecode.c a3a1aff30fe99a818d8e7c607980f033f40c68d890e03ed25838b9dbb7908bee F src/whereexpr.c 2a05552e808047a93845278c98c6ca64a265fa8e9ffd087c161bb11bfe339866 F src/window.c edd6f5e25a1e8f2b6f5305b7f5f7da7bb35f07f0d432b255b1d4c2fcab4205aa F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 @@ -1882,7 +1882,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 80ecdb3da4558bb08ee3ec6edbde906ad5b3b8182e672b5ba0d5dfa8041cee0a -R dfdf44d9d15025cae1d422e1f9b62b84 +P c0400f8c0bcb85ba39004feff753eae2f8e82065539e52b5788febd7644c417b +R e1c1402cbd7b36c23875003c93c1e06d U drh -Z b28f55587f68b7dba642183fc1b4bbee +Z 8d7eee9f9ee229c119f7fa4a4d9e03ee diff --git a/manifest.uuid b/manifest.uuid index 963e6b1610..12bb46f7d1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c0400f8c0bcb85ba39004feff753eae2f8e82065539e52b5788febd7644c417b \ No newline at end of file +ad5ab24ebd557e7af1d92ab3fbcb3747c04da5ad4ed779fb6391dc94042687dd \ No newline at end of file diff --git a/src/where.c b/src/where.c index 8a33e86194..ae0af8562e 100644 --- a/src/where.c +++ b/src/where.c @@ -2536,7 +2536,7 @@ static int whereLoopAddBtreeIndex( /* "x IN (value, value, ...)" */ nIn = sqlite3LogEst(pExpr->x.pList->nExpr); } - if( pProbe->hasStat1 ){ + if( pProbe->hasStat1 && rLogSize>=10 ){ LogEst M, logK, safetyMargin; /* Let: ** N = the total number of rows in the table @@ -2555,7 +2555,8 @@ static int whereLoopAddBtreeIndex( ** a safety margin of 2 (LogEst: 10) that favors using the IN operator ** with the index, as using an index has better worst-case behavior. ** If we do not have real sqlite_stat1 data, always prefer to use - ** the index. + ** the index. Do not bother with this optimization on very small + ** tables (less than 2 rows) as it is pointless in that case. */ M = pProbe->aiRowLogEst[saved_nEq]; logK = estLog(nIn); diff --git a/src/wherecode.c b/src/wherecode.c index 3fe67e384d..4afe0ac9c9 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -1809,12 +1809,7 @@ Bitmask sqlite3WhereCodeOneLoopStart( op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev]; assert( op!=0 ); - assert( op==OP_SeekGE - || (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 - || (db->flags & SQLITE_ReverseOrder)!=0 ); - if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 - && op==OP_SeekGE /* OP_SeekScan only does forward scans */ - ){ + if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 && op==OP_SeekGE ){ assert( regBignull==0 ); /* TUNING: The OP_SeekScan opcode seeks to reduce the number ** of expensive seek operations by replacing a single seek with