Commit Graph

702 Commits

Author SHA1 Message Date
drh
ee73b87181 Better determination of when an index is UNIQUE.
FossilOrigin-Name: 63fd025ad98c33826342824c51436ac92e2bb579
2013-06-04 13:37:26 +00:00
drh
ef71c1f090 Fix a display issue with EXPLAIN QUERY PLAN.
FossilOrigin-Name: ff2fa407558360f2499b6df0392ab3cdb4788dec
2013-06-04 12:58:02 +00:00
drh
7699d1c4e5 Refactor the ORDER BY optimizer in the NGQP so that it is easier to maintain
and so that it can support optimizing out GROUP BY and DISTINCT clauses.

FossilOrigin-Name: e605c468e3a1163167831c4a6220825c0b5d083b
2013-06-04 12:42:29 +00:00
drh
45c154ac90 Pull in recent trunk changes. Fix the ORDER BY optimizer so that it is better
able to deal with COLLATE clauses.  Clean up ambiguities in the descidx1.test
script.

FossilOrigin-Name: 6bc71dfcf0ef757c5c2b426dd8fddc1e5ae0f598
2013-06-03 20:46:35 +00:00
drh
e3b7c9216c Do not use an index fullscan for an UPDATE or DELETE or if disabled by
sqlite3_test_control() or sqlite3_config().

FossilOrigin-Name: fabb21854e662b1d8e5631e79f828d5322ceb595
2013-06-03 19:17:40 +00:00
drh
6f2bfad24b Update the NGQP to make use of STAT3 information if it is available.
FossilOrigin-Name: ff134e6ee95d41b0e59e03bba7e94bc15b04ff8c
2013-06-03 17:35:22 +00:00
drh
3b1d808fab Honor the orderByConsumed boolean returned from virtual table query planner.
FossilOrigin-Name: aaf7f5896d3523531e1a9a1b90c4ad326f0c8fc7
2013-06-03 16:56:37 +00:00
drh
5298630631 Fix to the logic that disables constraints on virtual tables.
FossilOrigin-Name: 62d382406b28c1347e13114f42215939ddfd7a9d
2013-06-03 16:03:16 +00:00
drh
3a5ba8b1b7 Fix an issue that was causing ORDER BY DESC to come out in ascending order.
FossilOrigin-Name: 029840124022387a8f6d2e1a685a003688d0ef3a
2013-06-03 15:34:48 +00:00
drh
21f7ff7d22 Set the WHERE_UNIQUE flag on loops that can only run once.
FossilOrigin-Name: 510f4d8ecf6eb284f14b91951e7236505bd71203
2013-06-03 15:07:23 +00:00
drh
75b9340520 The NGQP might not find a solution if INDEXED BY constraints on the query
are set wrong.  If that is the case, print a "no query solution" error
and abort before trying to use the non-existant solution.

FossilOrigin-Name: 42511a7e12a70cf3436d25e4d069e5d309dfd678
2013-05-31 20:43:57 +00:00
drh
79a13bfd1e Do not search using ON clause constraints of LEFT JOINs to the right of
the table.

FossilOrigin-Name: 723f901a63313b64a9f10516711fb6136526b79b
2013-05-31 20:28:28 +00:00
drh
a1f4124cf8 Make sure a unique cursor number is allocated for automatic indices.
FossilOrigin-Name: 433d1aecd399590b767ebf07b32023fb718a6574
2013-05-31 20:00:58 +00:00
drh
0edc94dcc7 Do not attempt to generate code in the NGQP if there have been prior errors,
since with prior errors some of the expressions might not be fully 
named resolved.

FossilOrigin-Name: 665e4291c6e78f11d7181c18c5f2418d1adfcb1c
2013-05-31 19:14:56 +00:00
drh
76f4cfb2e6 Fix a problem with code generation on LEFT JOIN of tables without an index.
FossilOrigin-Name: 0b1bee92a0d25f409d5a95f484b05ddf10ae945f
2013-05-31 18:20:52 +00:00
drh
e22501721f Another virtual table fix in NGQP.
FossilOrigin-Name: 2f2ce4167728399cc30bef045aab500940af978c
2013-05-31 18:13:50 +00:00
drh
7e47cb8b75 Fix problems in the virtual table logic for NGQP.
FossilOrigin-Name: 23af28e24b8f7ffacd006978b25bab990a43b8c5
2013-05-31 17:55:27 +00:00
drh
8030dc7b1f Remove the definitions of objects that are no longer used: WhereCost,
WherePlan, and WhereBestIdx.

FossilOrigin-Name: 816f8add7e60de2ef8df4fdac090c244f8dbda39
2013-05-31 15:50:39 +00:00
drh
ae70cf1816 Allow tracing of whereLoopInsert() when the 0x8 bit is set on ".wheretrace".
Remove the use of sqlite_query_plan from where2.test.  Fix a bug in the
code generator for OR clause optimizations.

FossilOrigin-Name: 707f0323264c35be14847a6adc49a0dc5eaf4ad2
2013-05-31 15:18:46 +00:00
drh
0afb423fd3 Futher enhancements to the ORDER BY optimizer.
FossilOrigin-Name: d8efa5f8b60bc4c8df8bfad077f87f76f7ee9bf6
2013-05-31 13:36:32 +00:00
drh
d044d209f3 Improved detection of unnecessary ORDER BY clauses.
FossilOrigin-Name: 58805eb36b9975706e2c4e382689519454e9a504
2013-05-31 12:43:55 +00:00
drh
53b52f7f2e Fix the constructAutomaticIndex() routine so that it works with NGQP.
FossilOrigin-Name: 5e1e61399513b4a95fd93df2377a2603f1670063
2013-05-31 11:57:39 +00:00
drh
dc3cd4b020 Improvements to the ORDER BY suppressor in the NGQP.
FossilOrigin-Name: 24a2e9ddcecd3926817d77abbb75d068ee7140ad
2013-05-30 23:21:20 +00:00
drh
1b0f026dbb Incremental check-in with various NGQP fixes. Many tests still fail.
FossilOrigin-Name: a51d8c92496436488e1a6eabd85785e8fedf2736
2013-05-30 22:27:09 +00:00
drh
6fa978dade Futher simplifications to the NGQP. Fix some test cases to use
EXPLAIN QUERY PLAN rather than the (now obsolete) sqlite_query_plan
global variable.

FossilOrigin-Name: ae985db4fa08b5efbef5a834e852f0b05101264b
2013-05-30 19:29:19 +00:00
drh
7ba39a921a Cut over the NGQP query planner. Remove lots of legacy code.
This check-in compiles but does not work.  The test suite gets incorrect
answers and crashes.

FossilOrigin-Name: 001539df4b74dc1cbceb010a91407003ab4d8735
2013-05-30 17:43:19 +00:00
drh
88da644f2c Update the NGQP to record which loops need be run in reverse order to
satisfy ORDER BY clauses.

FossilOrigin-Name: 211f7a5374fe20a02535edc8b799a8a7136ff6b3
2013-05-27 17:59:37 +00:00
drh
3bd26f0543 Record in the WhereLoop object the set of virtual table constraints that
need not be separately checked.

FossilOrigin-Name: b49fa74561f38c945be6149693678fd6518c2de4
2013-05-24 14:52:03 +00:00
drh
ef86637655 Use the NGQP plan for EXPLAIN QUERY PLAN output. This change causes 207
errors in veryquick.test, many of which are benign.

FossilOrigin-Name: f783e8e6b10de44029c7c5f57e4648a4a677ca1b
2013-05-22 20:49:02 +00:00
drh
0f133a4832 Allow the rowid at the end of an index to be used in a constraint on that index.
FossilOrigin-Name: 9bf0524df7ca2e7fcd92b2878a8457264b3c7f6e
2013-05-22 17:01:17 +00:00
drh
a50ef114f4 Improvements to ORDER BY handling in the NGQP. Fix an "exit" mistakenly
left in a test script during the previous check-in.

FossilOrigin-Name: 12c709b4369c7d94d7fb743d0d0da7a9350a3d16
2013-05-22 02:06:59 +00:00
drh
d15cb17174 Enhanced "wheretrace" output in the NGQP solver routine.
FossilOrigin-Name: 04dfb85a2a7025d4b5056b73fa8477691323919f
2013-05-21 19:23:10 +00:00
drh
23f98daabb Work toward improving the NGQP's ability to optimize out ORDER BY clauses.
FossilOrigin-Name: 67367f1e1f0c3eb6be65eea9873910aa62b49884
2013-05-21 15:52:07 +00:00
drh
319f677d57 First attempt to get ORDER BY optimization working in NGQP.
FossilOrigin-Name: 9fe20292558bb9422de91e35648cb834cbf3b306
2013-05-14 15:31:07 +00:00
drh
0823c89c9b Minor fixes to the OR-clause processing in the NGQP.
FossilOrigin-Name: d6946f33c7851aa7efb04b93ac2ae1ac50c26eec
2013-05-11 00:06:23 +00:00
drh
cf8fa7a65b Now generating OR-clause plans.
FossilOrigin-Name: e17003fcfec0c0b524b1b9ff8e15e7ee83efa571
2013-05-10 20:26:22 +00:00
drh
eb04de3224 Update the NGQP so that it can produce plans that include automatic indices.
FossilOrigin-Name: 586b55d8d7722de1c0530b3b832bae0511e6d05c
2013-05-10 15:16:30 +00:00
drh
b2a90f09b8 Factor out common operations into whereLoopAddAll(). Add stubs for
missing features.

FossilOrigin-Name: 0278e420614e02fb2d8474ed99b0904275882dfe
2013-05-10 03:30:49 +00:00
drh
2b344c7220 Merge in the latest trunk changes.
FossilOrigin-Name: 5ed31c8279a4f465b982df5dc20cefc286928b93
2013-05-10 02:11:40 +00:00
drh
6b7157bbd5 Free up bits of wsFlags for reuse. Install the ORDER BY optimization
infrastructure for the NGQP.

FossilOrigin-Name: 82d50e198025a2fdb8ee733edb8419d388ee5362
2013-05-10 02:00:35 +00:00
drh
b3129fa560 Do not move WHERE clause terms inside OR expressions that are contained
within an ON clause of a LEFT JOIN.  Fix for ticket [f2369304e47167e3e].

FossilOrigin-Name: 1128575d0ab24f7023a0f6e6ce4828b9a09a7c6c
2013-05-09 14:20:11 +00:00
drh
c718f1c894 Fix memory leaks in the NGQP logic for virtual tables.
FossilOrigin-Name: 3c2e83a4a2c5e85202162feeb37ef7a3911c05a3
2013-05-08 20:05:58 +00:00
drh
5346e95dda NGQP working with virtualt tables, though many legacy tests fail and there
are yet some memory leaks.

FossilOrigin-Name: bd9327a9684b99978734ccd561eea1ad864ab13b
2013-05-08 14:14:26 +00:00
drh
a184fb87b8 More bug fixes to the WhereLoop generator and the solver in NGQP.
Now finds the best plan for TPC-H Q8.  This seems to prove the
concept, but there is still much work to be done.

FossilOrigin-Name: 8e5aad37529ec3042e3468acf15186f566e2df8a
2013-05-08 04:22:59 +00:00
drh
f204dac1e3 Bug fixes in the solver.
FossilOrigin-Name: b36034bbd19bc5677b26a6f60ca96eb2b37db373
2013-05-08 03:22:07 +00:00
drh
a18f3d271e Add the NGQP solver.
FossilOrigin-Name: 5d37587c50d8932b6357bfd03152a851510a4317
2013-05-08 03:05:41 +00:00
drh
43fe25fcef Continued progress on generating good WhereLoop objects for the new query
planner.

FossilOrigin-Name: 15cc8a16482777d8e138c4d0863faf8d54fef33a
2013-05-07 23:06:23 +00:00
drh
f1645f0843 Inserting a few WhereLoop objects without leaking memory. Costs are
not correct.  Inequality and IN constraints are not implemented.

FossilOrigin-Name: e8881a8b2f25f38bc8ff77619f96f38fe530d13b
2013-05-07 19:44:38 +00:00
drh
1c8148fffb In where.c, make findTerm() a wrapper around methods to a new WhereScan object
which is capable of finding all suitable matching terms, not just the first.
This check-in includes some prototype functions for building WhereLoop objects.

FossilOrigin-Name: dd92b8fa929badaf2f79e8a00c83667a9d589096
2013-05-04 20:25:23 +00:00
drh
f1b5f5b855 Begin inserting some experimental code for the next generation query planner.
FossilOrigin-Name: ccaf4c3f7e1ec45e058d594d9b5c26818a37722a
2013-05-02 00:15:01 +00:00