In the query planner, add a heuristic that will reduce the cost of a full
table scan for a materialized view or subquery if the full scan is the outer-most loop. This is shown to speed up some queries. FossilOrigin-Name: 609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137
This commit is contained in:
parent
9c3a114ca0
commit
a3fc683c80
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Enhance\sthe\sb-tree\spage\ssorting\scode\sto\sensure\sthat\ssqlite3PagerRekey()\snever\noverloads\sa\spage\snumber\sand\suses\sonly\sthe\sPENDING_BYTE\spage\sfor\stemporary\nstorage.
|
||||
D 2022-08-31T15:04:42.204
|
||||
C In\sthe\squery\splanner,\sadd\sa\sheuristic\sthat\swill\sreduce\sthe\scost\sof\sa\sfull\ntable\sscan\sfor\sa\smaterialized\sview\sor\ssubquery\sif\sthe\sfull\sscan\sis\sthe\nouter-most\sloop.\s\sThis\sis\sshown\sto\sspeed\sup\ssome\squeries.
|
||||
D 2022-09-01T10:29:02.873
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -675,8 +675,8 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||
F src/where.c 6d1ee6f6bc048406554176eb6146b27ac16ec96cca018848aa0b9836b2b71143
|
||||
F src/whereInt.h b48ca529ffe293c18cbfa8326af18a09e39910de66fb3e96ef788c7cbf8ef3a7
|
||||
F src/where.c 424c42590b71968a9b81cd890df2671902028613fee38a50ed4c2f7ca65315d3
|
||||
F src/whereInt.h 70cd30de9ed784aa33fa6bd1245f060617de7a00d992469b6d8e419eed915743
|
||||
F src/wherecode.c 6bb1cf9d0a4e3e04dab0bf0ea4a8d936a0dcc05a7e2207beeda6c61aea6dd341
|
||||
F src/whereexpr.c 55a39f42aaf982574fbf52906371a84cceed98a994422198dfd03db4fce4cc46
|
||||
F src/window.c 928e215840e2f2d9a2746e018c9643ef42c66c4ab6630ef0df7fa388fa145e86
|
||||
@ -1852,7 +1852,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
|
||||
F test/win32lock.test e0924eb8daac02bf80e9da88930747bd44dd9b230b7759fed927b1655b467c9c
|
||||
F test/win32longpath.test 4baffc3acb2e5188a5e3a895b2b543ed09e62f7c72d713c1feebf76222fe9976
|
||||
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
|
||||
F test/window1.test ae87c4ea4e689725c7e1c826ab2b10704d5b6d31f9b9e5abadded996ba53a1d4
|
||||
F test/window1.test 08bac934238ff66987635ea3367c5aed5b4c088c414441beaba426e68a8257c1
|
||||
F test/window2.tcl 492c125fa550cda1dd3555768a2303b3effbeceee215293adf8871efc25f1476
|
||||
F test/window2.test e466a88bd626d66edc3d352d7d7e1d5531e0079b549ba44efb029d1fbff9fd3c
|
||||
F test/window3.tcl acea6e86a4324a210fd608d06741010ca83ded9fde438341cb978c49928faf03
|
||||
@ -1876,7 +1876,7 @@ F test/windowfault.test 15094c1529424e62f798bc679e3fe9dfab6e8ba2f7dfe8c923b6248c
|
||||
F test/windowpushd.test d8895d08870b7226f7693665bd292eb177e62ca06799184957b3ca7dc03067df
|
||||
F test/with1.test 9ad67fdeb2bbd808a5763c9060e214ea232f9b18d846ea3a59756dc38bdc3880
|
||||
F test/with2.test a1df41b987198383b9b70bf5e5fda390582e46398653858dbc6ceb24253b28df
|
||||
F test/with3.test ad32d13ad50661e6fa305f62a0717649c348792e7b658bf2644976227a9e0373
|
||||
F test/with3.test 1e2e8d5e7b1d955342d0d18c250aaaa6e6bcf36ef2a818477bd01cb74f9a5d66
|
||||
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
|
||||
F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8
|
||||
F test/with6.test c18592592b5a1c5802fd4e933d506f7b34ebbe8fdd585229793e960ae58d433f
|
||||
@ -1999,8 +1999,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 dd017bb1b3e31c7692d29dc4865d6bda871e429978c8738a39160d0114e5bf9b
|
||||
R 98122ff0aaf5ca87deda59c5c8a25251
|
||||
P 5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435
|
||||
R 5af1ce0d7f6d60d5f513975f3a1b9fe9
|
||||
U drh
|
||||
Z 8d73d18db9ab73a94a9689d17f937c1d
|
||||
Z 1d09512c855de39ee2d5b2ad872e6d10
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
5007742886bd20de20be3973737cf46b010359911615eb3da69cd262bd9a2435
|
||||
609fbb94b8f01d6792e5941ab23ce041313d359f6788c4dde6b1ca749ab49137
|
10
src/where.c
10
src/where.c
@ -3463,6 +3463,9 @@ static int whereLoopAddBtree(
|
||||
#else
|
||||
pNew->rRun = rSize + 16;
|
||||
#endif
|
||||
if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){
|
||||
pNew->wsFlags |= WHERE_VIEWSCAN;
|
||||
}
|
||||
ApplyCostMultiplier(pNew->rRun, pTab->costMult);
|
||||
whereLoopOutputAdjust(pWC, pNew, rSize);
|
||||
rc = whereLoopInsert(pBuilder, pNew);
|
||||
@ -4843,6 +4846,13 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
|
||||
rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
|
||||
}
|
||||
|
||||
/* TUNING: A full-scan of a VIEW or subquery in the outer loop
|
||||
** is not so bad. */
|
||||
if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){
|
||||
rCost += -10;
|
||||
nOut += -30;
|
||||
}
|
||||
|
||||
/* Check to see if pWLoop should be added to the set of
|
||||
** mxChoice best-so-far paths.
|
||||
**
|
||||
|
@ -648,5 +648,6 @@ void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
|
||||
#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */
|
||||
#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */
|
||||
#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */
|
||||
#define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */
|
||||
|
||||
#endif /* !defined(SQLITE_WHEREINT_H) */
|
||||
|
@ -212,10 +212,11 @@ do_execsql_test 6.1 {
|
||||
} {1 1 2 2 3 3 4 4 5 5 6 6 7 7}
|
||||
|
||||
do_execsql_test 6.2 {
|
||||
SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1);
|
||||
SELECT * FROM t2, (SELECT x, count(*) OVER (ORDER BY x) FROM t1)
|
||||
ORDER BY 1, 2;
|
||||
} {
|
||||
b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7
|
||||
a 1 1 a 2 2 a 3 3 a 4 4 a 5 5 a 6 6 a 7 7
|
||||
b 1 1 b 2 2 b 3 3 b 4 4 b 5 5 b 6 6 b 7 7
|
||||
}
|
||||
|
||||
do_catchsql_test 6.3 {
|
||||
|
@ -131,8 +131,8 @@ do_eqp_test 3.2.2 {
|
||||
| | `--SCALAR SUBQUERY xxxxxx
|
||||
| | `--SCAN w2
|
||||
| `--RECURSIVE STEP
|
||||
| |--SCAN w1
|
||||
| `--SCAN c
|
||||
| |--SCAN c
|
||||
| `--SCAN w1
|
||||
|--SCAN c
|
||||
|--SEARCH w2 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
`--SEARCH w1 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
|
Loading…
Reference in New Issue
Block a user