]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove the push-down optimization restriction that was added by
authordrh <>
Wed, 22 Feb 2023 20:42:15 +0000 (20:42 +0000)
committerdrh <>
Wed, 22 Feb 2023 20:42:15 +0000 (20:42 +0000)
check-in [1ad41840c5e0fa70] because it is no longer needed after
the enhancements to compound query processing in check-in [27655c9353620aa5]
This resolves the performance regression reported by
[forum:/forumpost/bcc4375032|forum post bcc4375032].

FossilOrigin-Name: aa6bd6dff751223e302575c60f335707e4bb820bff716cab3706b564e18ed7ed

manifest
manifest.uuid
src/select.c
test/pushdown.test

index 00adf2e1b0017c53fc3be53e39c052ba784f07c5..4c15df292f32955f1e03b5d7b303f7aca7d92d86 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\ssome\sunnecessary\sbind()\scalls\sin\sJS\scode.
-D 2023-02-21T20:08:10.896
+C Remove\sthe\spush-down\soptimization\srestriction\sthat\swas\sadded\sby\ncheck-in\s[1ad41840c5e0fa70]\sbecause\sit\sis\sno\slonger\sneeded\safter\nthe\senhancements\sto\scompound\squery\sprocessing\sin\scheck-in\s[27655c9353620aa5]\nThis\sresolves\sthe\sperformance\sregression\sreported\sby\n[forum:/forumpost/bcc4375032|forum\spost\sbcc4375032].
+D 2023-02-22T20:42:15.004
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -621,7 +621,7 @@ F src/printf.c ff4b05e38bf928ff1b80d3dda4f977b10fe39ecbfe69c018224c7e5594fb2455
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c d62c5665279cc7485f9d45b5e20911cc7b19c203f268321a90d05d74f4725750
 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
-F src/select.c d44e78e103cb52b3bdf8d0b7ac2518b7a4cbaf12237bd9078f6897d230d2516e
+F src/select.c f80d98f13fa64201ababf5e80d682c430559cd7ee00ab14ee99a1aeb27ac097d
 F src/shell.c.in 6f36f5ca05f1bebf74935a7fcf2dce983016e807a09cbd752a673583ad7da087
 F src/sqlite.h.in 662a2fa083d093896b92560c871dea6d86792b49dc4bf7b4e8dbeca8e7171488
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
@@ -1385,7 +1385,7 @@ F test/printf.test 390d0d7fcffc3c4ea3c1bb4cbb267444e32b33b048ae21895f23a291844fe
 F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60
 F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb
 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
-F test/pushdown.test f270b8071c02efc218430e0d388c155e1962eaa1d3a3ab186dd38ad6d7e178a4
+F test/pushdown.test 35c23334e5d29d90b1f8360879352dc84d6d5d08aa434b82e455d015823b7c30
 F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca
 F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
 F test/quickcheck.test f86b25b33455af0189b4d3fe7bd6e553115e80b2d7ec9bbe9a6b37fce0881bfe
@@ -2045,8 +2045,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b5e0b69649e6341ffff4e62f9f68abd2a53519f73964559a133f3b708e007e98
-R dd3f5c20eacca5476bd8e8ef24e7cee2
-U stephan
-Z 4ba8ee1ea4c59526ff8ff4648a8a2201
+P 71215599cd8ebb970500d8366dfac40420a9a6b243ea9d6ba62d5cde28fae3d3
+R b7b0698140aa56dfbaf179da7c992bef
+U drh
+Z 71e4a1ce17f1f7f2e2a274a357385131
 # Remove this line to create a well-formed Fossil manifest.
index bd009ded60f2f165c7af187fa54b6522e6efc936..6c00e3fb60e88c8482b0a1396a5bd12d6d7920c4 100644 (file)
@@ -1 +1 @@
-71215599cd8ebb970500d8366dfac40420a9a6b243ea9d6ba62d5cde28fae3d3
\ No newline at end of file
+aa6bd6dff751223e302575c60f335707e4bb820bff716cab3706b564e18ed7ed
\ No newline at end of file
index 1b5a1b506ebb5d3bc4f8e298280ef31298ed9841..23099b13970cf1f9e70baeaee6657c482484e381 100644 (file)
@@ -4238,8 +4238,7 @@ static int compoundHasDifferentAffinities(Select *p){
 **              query or there are no RIGHT or FULL JOINs in any arm
 **              of the subquery.  (This is a duplicate of condition (27b).)
 **        (17h) The corresponding result set expressions in all arms of the
-**              compound must have the same affinity. (See restriction (9)
-**              on the push-down optimization.)
+**              compound must have the same affinity.
 **
 **        The parent and sub-query may contain WHERE clauses. Subject to
 **        rules (11), (13) and (14), they may also contain ORDER BY,
@@ -5107,10 +5106,6 @@ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){
 **       or EXCEPT, then all of the result set columns for all arms of
 **       the compound must use the BINARY collating sequence.
 **
-**   (9) If the subquery is a compound, then all arms of the compound must
-**       have the same affinity.  (This is the same as restriction (17h)
-**       for query flattening.)
-**       
 **
 ** Return 0 if no changes are made and non-zero if one or more WHERE clause
 ** terms are duplicated into the subquery.
@@ -5141,9 +5136,6 @@ static int pushDownWhereTerms(
       if( pSel->pWin ) return 0;    /* restriction (6b) */
 #endif
     }
-    if( compoundHasDifferentAffinities(pSubq) ){
-      return 0;  /* restriction (9) */
-    }
     if( notUnionAll ){
       /* If any of the compound arms are connected using UNION, INTERSECT,
       ** or EXCEPT, then we must ensure that none of the columns use a
index ca816fb2138a9ec3a5d1bbe14b121866836d9e37..660827e4e46755a6f0dadcfed1c8a6de3077489d 100644 (file)
@@ -122,5 +122,45 @@ do_execsql_test 3.4 {
 } {
   2 0     0
 }
-  
+
+# 2023-02-22 https://sqlite.org/forum/forumpost/bcc4375032
+# Performance regression caused by check-in [1ad41840c5e0fa70] from 2022-11-25.
+# That check-in added a new restriction on push-down.  The new restriction is
+# no longer necessary after check-in [27655c9353620aa5] from 2022-12-14.
+#
+do_execsql_test 3.5 {
+  DROP TABLE IF EXISTS t1;
+  CREATE TABLE t1(a INT, b INT, c TEXT, PRIMARY KEY(a,b)) WITHOUT ROWID;
+  INSERT INTO t1(a,b,c) VALUES
+    (1,100,'abc'),
+    (2,200,'def'),
+    (3,300,'abc');
+  DROP TABLE IF EXISTS t2;
+  CREATE TABLE t2(a INT, b INT, c TEXT, PRIMARY KEY(a,b)) WITHOUT ROWID;
+  INSERT INTO t2(a,b,c) VALUES
+    (1,110,'efg'),
+    (2,200,'hij'),
+    (3,330,'klm');
+  CREATE VIEW v3 AS
+    SELECT a, b, c FROM t1
+    UNION ALL
+    SELECT a, b, 'xyz' FROM t2;
+  SELECT * FROM v3 WHERE a=2 AND b=200;
+} {2 200 def 2 200 xyz}
+do_eqp_test 3.6 {
+  SELECT * FROM v3 WHERE a=2 AND b=200;
+} {
+  QUERY PLAN
+  |--CO-ROUTINE v3
+  |  `--COMPOUND QUERY
+  |     |--LEFT-MOST SUBQUERY
+  |     |  `--SEARCH t1 USING PRIMARY KEY (a=? AND b=?)
+  |     `--UNION ALL
+  |        `--SEARCH t2 USING PRIMARY KEY (a=? AND b=?)
+  `--SCAN v3
+}
+#                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+# We want both arms of the compound subquery to use the
+# primary key.
+
 finish_test