Compare commits

...

1 Commits

Author SHA1 Message Date
drh c0359f0490 If a subquery is used to drive an index, this change avoids making an extra
copy of the result of that subquery.  But, such situations are probably
sufficiently unusual that the added complexity of this enhancement is not
worth the performance gain.  So I'm going to park this check-in on a branch.
If we later find a use case to justify it, we can merge it to trunk then.
This is the "further change" that was promised by the prior check-in comment.

FossilOrigin-Name: 4488cb883e155a7466946d25569ab2816c4a8de9d4c7d540f5053ea5334e7ae5
2021-05-28 14:28:54 +00:00
3 changed files with 16 additions and 8 deletions
+9 -6
View File
@@ -1,5 +1,5 @@
C Make\sa\sdeep\scopy\sof\sthe\sresult\sof\sa\ssubquery\sin\scase\sthe\ssubquery\sis\nreused.\s\sFix\sfor\sthe\sproblem\sreported\sby\n[forum:/forumpost/28216b36ac|forum\spost\s28216b36ac]\sand\sintroduced\sby\ncheck-in\s[f30fb19ff763a7cb].\s\sFurther\schanges\sto\stry\sto\soptimize\sthe\snew\nOP_Copy\sopcode\sback\sinto\seither\sOP_SCopy\sor\sOP_Move\swill\sbe\sattempted\nseparately.\s\sA\stest\scase\swill\sbe\sin\sTH3.
D 2021-05-28T12:48:31.685
C If\sa\ssubquery\sis\sused\sto\sdrive\san\sindex,\sthis\schange\savoids\smaking\san\sextra\ncopy\sof\sthe\sresult\sof\sthat\ssubquery.\s\sBut,\ssuch\ssituations\sare\sprobably\nsufficiently\sunusual\sthat\sthe\sadded\scomplexity\sof\sthis\senhancement\sis\snot\nworth\sthe\sperformance\sgain.\s\sSo\sI'm\sgoing\sto\spark\sthis\scheck-in\son\sa\sbranch.\nIf\swe\slater\sfind\sa\suse\scase\sto\sjustify\sit,\swe\scan\smerge\sit\sto\strunk\sthen.\nThis\sis\sthe\s"further\schange"\sthat\swas\spromised\sby\sthe\sprior\scheck-in\scomment.
D 2021-05-28T14:28:54.261
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -633,7 +633,7 @@ F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c 7342becedf3f8a26f9817f08436bdf8b56ad69af83705f6b9320a0ad3092c2ac
F src/where.c 32f41c3c93c6785e0077e3a2cdc669c3ccfe70173787847be77f294c18fc7dc3
F src/whereInt.h 9248161dd004f625ce5d3841ca9b99fed3fc8d61522cf76340fc5217dbe1375b
F src/wherecode.c 9f1f65d11437b25cd0a1497a170514c785f19ce6ad9d3e6fc73719cb5a49012f
F src/wherecode.c bcfee3789a7d3da1f3f8a76c1b20c95d6c0fc4ea93c5d9b03206a432ac8b1cc4
F src/whereexpr.c 5a9c9f5d2dac4bcdcaae3035034b4667523f731df228e0bb1d4efc669efa9da5
F src/window.c a6d624d83b2d5b3cfb82bb437a2fbae759c928d47dc9ad1338a9419269181bb2
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
@@ -1918,7 +1918,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 21676731cedae27d1ab9fe62b269001ae6e3eeb3caa87b4f5536f777631a8bbc
R 77e951a6e7b5327d1f646c5968da6983
P c9f0b9cb0aef107265435e22c164dd3c974eadfd00abf7cfd4fc7ec95c0dd7d0
R c044497982752ba303617f7de106b59c
T *branch * copy-optimization
T *sym-copy-optimization *
T -sym-trunk *
U drh
Z 20c9ad1ef6610380252081cdda3138d3
Z 0c06d6f1ffda88b03d3d1e66ad233058
+1 -1
View File
@@ -1 +1 @@
c9f0b9cb0aef107265435e22c164dd3c974eadfd00abf7cfd4fc7ec95c0dd7d0
4488cb883e155a7466946d25569ab2816c4a8de9d4c7d540f5053ea5334e7ae5
+6 -1
View File
@@ -752,11 +752,16 @@ static int codeAllEqualityTerms(
testcase( pTerm->wtFlags & TERM_VIRTUAL );
r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
if( r1!=regBase+j ){
assert( pTerm->pExpr->op==TK_EQ || pTerm->pExpr->op==TK_IS );
if( nReg==1 ){
sqlite3ReleaseTempReg(pParse, regBase);
regBase = r1;
}else{
sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
if( ExprHasProperty(pTerm->pExpr->pRight, EP_VarSelect) ){
sqlite3VdbeAddOp3(v, OP_Move, r1, regBase+j, 1);
}else{
sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
}
}
}
if( pTerm->eOperator & WO_IN ){