Improve the query planner so that it is better able to find full
index scan plan when there is an INDEXED BY clause. FossilOrigin-Name: d901837fea1ed54de43ad59eb47c02cbfd2eb215fc57317b5ea8c22a7df947c4
This commit is contained in:
parent
e566cebb26
commit
094afffaec
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Draw\sthe\sdashes\sbelow\sthe\sheaders\sin\s"explain"\smode\sin\sthe\sCLI.
|
||||
D 2020-05-30T15:34:49.222
|
||||
C Improve\sthe\squery\splanner\sso\sthat\sit\sis\sbetter\sable\sto\sfind\sfull\nindex\sscan\splan\swhen\sthere\sis\san\sINDEXED\sBY\sclause.
|
||||
D 2020-06-03T03:00:09.331
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -620,7 +620,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c 04c3d2a673192016a671eb051a1900945a8c7331f4378636a8bfb70e8e596c84
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/walker.c 3df26a33dc4f54e8771600fb7fdebe1ece0896c2ad68c30ab40b017aa4395049
|
||||
F src/where.c 9546c82056e8cdb27291f98cf1adca5d271240b399bb97b32f77fc2bea6146c9
|
||||
F src/where.c 7bcc07ff56d03d73308245135d96de46d2faeaee628bd4badf0bae60ae6a31fe
|
||||
F src/whereInt.h 6b874aa15f94e43a2cec1080be64d955b04deeafeac90ffb5d6975c0d511be3c
|
||||
F src/wherecode.c 7b939de85d65cc4b4bfa197513136b9e0ae03167e3b82842ca5a0ba1055ba65d
|
||||
F src/whereexpr.c 264d58971eaf8256eb5b0917bcd7fc7a1f1109fdda183a8382308a1b18a2dce7
|
||||
@ -1070,7 +1070,7 @@ F test/index6.test f172653b35b20233e59200e8b92a76db61bf7285437bf777b93b306ba26a4
|
||||
F test/index7.test b8a0ba2110fd517bb48c4e76d26d60f1ab2ed9e257b18d71f820d7e71e9f8570
|
||||
F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7
|
||||
F test/index9.test 0aa3e509dddf81f93380396e40e9bb386904c1054924ba8fa9bcdfe85a8e7721
|
||||
F test/indexedby.test a52c8c6abfae4fbfb51d99440de4ca1840dbacc606b05e29328a2a8ba7cd914e
|
||||
F test/indexedby.test f54aac21c06948872010a956fd02de5178c362c7785a9887cf0b8616be17883b
|
||||
F test/indexexpr1.test 284e119999d132cc8bf37735a928c9859b28e8e295d02b7a6a4f93977c7f9ba5
|
||||
F test/indexexpr2.test dba11dbb0a58fcba4cd694f46b4004976123b81b0501f525d43c9be59f0207b1
|
||||
F test/indexfault.test 98d78a8ff1f5335628b62f886a1cb7c7dac1ef6d48fa39c51ec871c87dce9811
|
||||
@ -1706,7 +1706,7 @@ F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
|
||||
F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b
|
||||
F test/where7.test 75722434c486ac9e74718caa6cce234f45ba34c0b6c0f9555b29eb8bb5f6ade1
|
||||
F test/where8.test 461ca40265ed996a6305da99bb024b0e41602bb586acf544c08f95922358e49f
|
||||
F test/where9.test 2c554b97bbdb2fdf26c57099f60db8a52bfcf7c147f2c256f9798fa0e267ca85
|
||||
F test/where9.test 8e3e0ff42cc17156f52361a1c012281550d0d632912fec92d1d6df74db7a8e6d
|
||||
F test/whereA.test 6c6a420ca7d313242f9b1bd471dc80e4d0f8323700ba9c78df0bb843d4daa3b4
|
||||
F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5
|
||||
F test/whereC.test cae295158703cb3fc23bf1a108a9ab730efff0f6
|
||||
@ -1866,7 +1866,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 1cb248a3fc4c35c5bc3993b554edcccaa5c5e91570af67ebb99643a15221ae33
|
||||
R 8b6d070d9470292acffd6f600425ba3f
|
||||
P c6b7833ac7d9cc75cb45d5e8041367ebd6f197f776766e6143535c227fc72a20
|
||||
R 952d1a55f39aa3fb3430db1783a8d16a
|
||||
U drh
|
||||
Z 86932043c882c09459de0bf040004fa9
|
||||
Z 7e892dc73a9c345df1500a78da6d8191
|
||||
|
@ -1 +1 @@
|
||||
c6b7833ac7d9cc75cb45d5e8041367ebd6f197f776766e6143535c227fc72a20
|
||||
d901837fea1ed54de43ad59eb47c02cbfd2eb215fc57317b5ea8c22a7df947c4
|
@ -3028,6 +3028,7 @@ static int whereLoopAddBtree(
|
||||
pNew->nOut = rSize;
|
||||
pNew->u.btree.pIndex = pProbe;
|
||||
b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);
|
||||
|
||||
/* The ONEPASS_DESIRED flags never occurs together with ORDER BY */
|
||||
assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );
|
||||
if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){
|
||||
@ -3057,6 +3058,7 @@ static int whereLoopAddBtree(
|
||||
if( b
|
||||
|| !HasRowid(pTab)
|
||||
|| pProbe->pPartIdxWhere!=0
|
||||
|| pSrc->fg.isIndexedBy
|
||||
|| ( m==0
|
||||
&& pProbe->bUnordered==0
|
||||
&& (pProbe->szIdxRow<pTab->szTabRow)
|
||||
|
@ -95,7 +95,7 @@ do_test indexedby-2.4 {
|
||||
# an error.
|
||||
do_test indexedby-2.4.1 {
|
||||
catchsql { SELECT b FROM t1 INDEXED BY i1 WHERE b = 'two' }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
do_test indexedby-2.5 {
|
||||
catchsql { SELECT * FROM t1 INDEXED BY i5 WHERE a = 'one' AND b = 'two'}
|
||||
@ -135,10 +135,10 @@ do_eqp_test indexedby-3.3 {
|
||||
} {SEARCH TABLE t1 USING INDEX i2 (b=?)}
|
||||
do_test indexedby-3.4 {
|
||||
catchsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-3.5 {
|
||||
catchsql { SELECT * FROM t1 INDEXED BY i2 ORDER BY a }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-3.6 {
|
||||
catchsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' }
|
||||
} {0 {}}
|
||||
@ -154,7 +154,7 @@ do_eqp_test indexedby-3.9 {
|
||||
} {SEARCH TABLE t3 USING INDEX sqlite_autoindex_t3_1 (e=?)}
|
||||
do_test indexedby-3.10 {
|
||||
catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE f = 10 }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-3.11 {
|
||||
catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_2 WHERE f = 10 }
|
||||
} {1 {no such index: sqlite_autoindex_t3_2}}
|
||||
@ -172,19 +172,19 @@ do_eqp_test indexedby-4.2 {
|
||||
SELECT * FROM t1 INDEXED BY i1, t2 WHERE a = c
|
||||
} {
|
||||
QUERY PLAN
|
||||
|--SCAN TABLE t2
|
||||
`--SEARCH TABLE t1 USING INDEX i1 (a=?)
|
||||
|--SCAN TABLE t1 USING INDEX i1
|
||||
`--SEARCH TABLE t2 USING INDEX i3 (c=?)
|
||||
}
|
||||
do_test indexedby-4.3 {
|
||||
catchsql {
|
||||
SELECT * FROM t1 INDEXED BY i1, t2 INDEXED BY i3 WHERE a=c
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-4.4 {
|
||||
catchsql {
|
||||
SELECT * FROM t2 INDEXED BY i3, t1 INDEXED BY i1 WHERE a=c
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
# Test embedding an INDEXED BY in a CREATE VIEW statement. This block
|
||||
# also tests that nothing bad happens if an index refered to by
|
||||
@ -205,7 +205,7 @@ do_test indexedby-5.4 {
|
||||
# Recreate index i1 in such a way as it cannot be used by the view query.
|
||||
execsql { CREATE INDEX i1 ON t1(b) }
|
||||
catchsql { SELECT * FROM v2 }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-5.5 {
|
||||
# Drop and recreate index i1 again. This time, create it so that it can
|
||||
# be used by the query.
|
||||
@ -245,7 +245,7 @@ do_eqp_test indexedby-7.5 {
|
||||
} {SEARCH TABLE t1 USING INDEX i2 (b=?)}
|
||||
do_test indexedby-7.6 {
|
||||
catchsql { DELETE FROM t1 INDEXED BY i2 WHERE a = 5}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
# Test that "INDEXED BY" can be used in an UPDATE statement.
|
||||
#
|
||||
@ -266,7 +266,7 @@ do_eqp_test indexedby-8.5 {
|
||||
} {SEARCH TABLE t1 USING INDEX i2 (b=?)}
|
||||
do_test indexedby-8.6 {
|
||||
catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
# Test that bug #3560 is fixed.
|
||||
#
|
||||
@ -284,10 +284,10 @@ do_test indexedby-9.2 {
|
||||
joinme as j indexed by joinme_id_text_idx
|
||||
on ( m.id = j.id_int)
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test indexedby-9.3 {
|
||||
catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
# Make sure we can still create tables, indices, and columns whose name
|
||||
# is "indexed".
|
||||
|
@ -426,7 +426,7 @@ do_test where9-4.5 {
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {92 93 97}}
|
||||
do_test where9-4.6 {
|
||||
count_steps {
|
||||
SELECT a FROM t1 NOT INDEXED
|
||||
@ -442,7 +442,7 @@ do_test where9-4.7 {
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {92 93 97}}
|
||||
do_test where9-4.8 {
|
||||
catchsql {
|
||||
SELECT a FROM t1 INDEXED BY t1d
|
||||
@ -450,7 +450,7 @@ do_test where9-4.8 {
|
||||
AND (c=31031 OR d IS NULL)
|
||||
ORDER BY +a
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {92 93 97}}
|
||||
|
||||
# The (c=31031 OR d IS NULL) clause is preferred over b>1000 because
|
||||
# the former is an equality test which is expected to return fewer rows.
|
||||
@ -776,7 +776,7 @@ do_test where9-6.8.1 {
|
||||
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test where9-6.8.2 {
|
||||
catchsql {
|
||||
UPDATE t1 INDEXED BY t1b SET a=a+100
|
||||
@ -784,7 +784,7 @@ do_test where9-6.8.2 {
|
||||
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
|
||||
set solution_possible 0
|
||||
ifcapable stat4 {
|
||||
@ -818,7 +818,7 @@ if $solution_possible {
|
||||
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
do_test where9-6.8.4 {
|
||||
catchsql {
|
||||
DELETE FROM t1 INDEXED BY t1b
|
||||
@ -826,7 +826,7 @@ if $solution_possible {
|
||||
OR (b NOT NULL AND c IS NULL AND d NOT NULL)
|
||||
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
|
||||
}
|
||||
} {1 {no query solution}}
|
||||
} {0 {}}
|
||||
}
|
||||
############################################################################
|
||||
# Test cases where terms inside an OR series are combined with AND terms
|
||||
|
Loading…
Reference in New Issue
Block a user