1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00
Commit Graph

968 Commits

Author SHA1 Message Date
drh
aa32e3c60a Enhance the query planner so that it looks at multiple solutions to OR
expressions in the WHERE clause.

FossilOrigin-Name: 5e19d054105fb16ff52d265d48cc87a418603f6f
2013-07-16 21:31:23 +00:00
drh
5e128b235b Make sure the schema is verified prior to processing a "WHERE 0" on the
first term of a compound SELECT statement.
Fix for ticket [490a4b723562429]

FossilOrigin-Name: 52a49cbc1621094b2fe2b021209b768d29e0426b
2013-07-09 03:04:32 +00:00
drh
b5246e518b Fix an adverse interaction between the IS NOT NULL optimization (available
only with SQLITE_ENABLE_STAT3) and the transitive constraint processing.
Fix for ticket [d805526eae253]

FossilOrigin-Name: 3b30b75b342bb6b424ad2bf7cd841b2c88bdad44
2013-07-08 21:12:57 +00:00
dan
b2cfc14670 Add missing "static" qualifier to functions in where.c.
FossilOrigin-Name: 5c906e914b63eb00e62c6c2a535e234a75d95030
2013-07-05 11:10:54 +00:00
drh
0d08b93673 Remove a surplus local variable
FossilOrigin-Name: 91bc840eea2099273bd2c5d41a8410d628986643
2013-07-02 15:25:22 +00:00
dan
51576f4791 Fix a minor typo in a comment in where.c.
FossilOrigin-Name: 4a9d51e792d7c4297bd18af7b7c757c93a3a1cd1
2013-07-02 10:06:15 +00:00
drh
cdc2e43d8e Add a missing test that prevented double LEFT JOINs with transitive
constraints from working correctly.  Fix for ticket [868145d012].

FossilOrigin-Name: 72919ec34f0d663d551c1070285ad93b932bcb74
2013-07-01 17:27:19 +00:00
drh
9443342ee9 Further minor comment corrections and enhancements in where.c.
FossilOrigin-Name: 0d68d4d018e73dcbbc08786071aac6228fca1a8c
2013-07-01 11:05:50 +00:00
drh
be4fe3afc0 Make a trivial comment fix in where.c.
FossilOrigin-Name: 0ffaab3b9c97f4dba0f0ca6e146c8dc2775f7b1c
2013-07-01 10:38:35 +00:00
drh
8d56e2059c Issue the new SQLITE_WARNING_AUTOINDEX warning on the SQLite log whenever
an automatic index is created.

FossilOrigin-Name: 338826ef3f8a209b14f8d42370855cab9ac9ed45
2013-06-28 23:55:45 +00:00
drh
986b38792f Add the SQLITE_DEFAULT_AUTOMATIC_INDEX compile-time option, which if set to
zero turns automatic indices off by default.  Increase the estimated cost
of an automatic index.  Additional minor refactoring of the automatic
index code.

FossilOrigin-Name: 459b3179023c2c45994ea4acbf34ed5f87cf3c18
2013-06-28 21:12:20 +00:00
drh
40aa936f7f Add a bit to the SQLITE_TESTCTRL_OPTIMIZATIONS option for sqlite3_file_control()
that will disable the use of SQLITE_STAT3 information in the query planner.

FossilOrigin-Name: 60c19b86797fb8a37f175545929883ebeff7f307
2013-06-28 17:29:25 +00:00
drh
9d5a579c35 Fix an issue with the OmitNoopJoin optimization and add test cases that
are specifically for that optimization.

FossilOrigin-Name: 5480d124b74c9adaacc4fa9cb81560865b44f3e1
2013-06-28 13:43:33 +00:00
drh
1031bd9958 Add the ability to disable the omit-join-table optimization for testing
purposes.

FossilOrigin-Name: d929df9b1ba214c27d8c437099a53ee9b07aa169
2013-06-22 15:44:26 +00:00
drh
bc71b1d453 Only eliminate inner loops of a JOIN if they are the RHS of a LEFT JOIN
and if they give no more than a single result.  This appears to give correct
answers in all cases.

FossilOrigin-Name: d7a25cc79794817504ca1a4262008a68b2a4dece
2013-06-21 02:15:48 +00:00
drh
fd636c7541 Attempt to disable inner loops of a join that do not generate output.
This does not work, since the inner loops might run zero times and thus
inhibit all output.  Needs to be enhanced to work only for LEFT JOINs
or when we know that the inner loop will always run at least once.

FossilOrigin-Name: ca839723a21bb13d3e0666a672c15c6f3a267c2f
2013-06-21 02:05:06 +00:00
drh
6457a353bc Modify the query planner interface so that it always passes in the result set.
This is the first step toward adding an optimization that will omit tables
from a join that do not contribute to the result.

FossilOrigin-Name: 2c2577e69ccb47f1af674a755e71221e2ca0b322
2013-06-21 00:35:37 +00:00
drh
472eae8a4d Add a NEVER() macro and an explanation comment around an unreachable branch
in the STAT3 logic.

FossilOrigin-Name: 604c3c5de6fd8f8a569aa9ed981055a5b0123ba1
2013-06-20 17:32:28 +00:00
drh
74f91d4462 Add in the cost of doing a table lookup on OR searches. Make test case
changes to deal with difference in STAT3 behavior.

FossilOrigin-Name: d97898e8e3990ae8c1882c9102b57692d8810730
2013-06-19 18:01:44 +00:00
drh
ad01d892a7 Additional compiler warning fixes.
FossilOrigin-Name: 8d2ae8e2f343f82f6fba6d0e89cee7f15b444aa3
2013-06-19 13:59:49 +00:00
drh
e8ae583ebd Fix a harmless uninitialized variable warning.
FossilOrigin-Name: 9d3ef3bd2c6281784a537a22a87279f420649935
2013-06-19 13:32:46 +00:00
drh
dbb80234da Simplify and add invariants to the WhereLoop merging logic inside of
whereLoopInsert().

FossilOrigin-Name: 8f27f35f288434b9e7bc503c608f1e2b590ade4d
2013-06-19 12:34:13 +00:00
drh
c7f0d229a7 Fix compiler warnings. Fix a harmless off-by-one error in the solver.
FossilOrigin-Name: 10021941d0258951b916e788881df140113f0597
2013-06-19 03:27:12 +00:00
drh
4a5acf8e5c Adjustments to testcase() macros for improved testability.
FossilOrigin-Name: 4fbb0c4d26c54aaefbe5397cde2a0b9d2ce3885f
2013-06-18 20:06:23 +00:00
drh
81186b4392 Remove some redundant and unreachable code.
FossilOrigin-Name: 4c6d58d75d51e1ce829aec214617c3a89e784a2d
2013-06-18 01:52:41 +00:00
drh
7963b0e853 Add more testcase() macros. Fix a memory leak following OOM in the
virtual table analysis logic.

FossilOrigin-Name: b61402af690ac08b68974f3c807096b0cffd9bc0
2013-06-17 21:37:40 +00:00
drh
93ec45d560 Simplifications to the NGQP. Add the queryplantest makefile target. Add
testcase() macros in the NGQP.

FossilOrigin-Name: eaf1f1b405ec2c498092527fae00e5dbe9e176c1
2013-06-17 18:20:48 +00:00
drh
75bf6b984a Use automatic indices on subqueries of the FROM clause when appropriate.
FossilOrigin-Name: e8f124284ee0d0e373dc4431668630f1e17015c1
2013-06-17 14:18:21 +00:00
drh
613ba1ea9c Fix compiler warnings.
FossilOrigin-Name: 3e8ac46918c68723bd199dbec8b0901457d524a9
2013-06-15 15:11:45 +00:00
drh
f003076032 Comment tweaks in where.c. No changes to code.
FossilOrigin-Name: cecc5fdd5d8fbad7d9e8c275b9ba9ade3dbee8ef
2013-06-14 13:27:01 +00:00
drh
b8916be945 Add a new ORDER BY optimization that bypasses ORDER BY terms that are
constrained by == and IS NULL terms of the WHERE clause.

FossilOrigin-Name: b920bb70bb009b7c54e7667544c9810c5ee25e19
2013-06-14 02:51:48 +00:00
drh
6d38147c19 An index might be useful for ORDER BY if any indexed column is in the
ORDER BY clause, not just the first indexed column.

FossilOrigin-Name: ade473b5ae3fe2162b0ec29731d8e864a9301e07
2013-06-13 17:58:08 +00:00
drh
53cfbe92d1 Make sure that disabling the covering index scan optimization does not
prevent a covering index from being used to satisfy an ORDER BY clause.

FossilOrigin-Name: e8b7ea8202c443bfc8a978588c7d2cfaa14a8fea
2013-06-13 17:28:22 +00:00
drh
bbe8b24b8d Restore the ability to do a BETWEEN query on the rowid. Also fix a
nearby comment.

FossilOrigin-Name: 459a7b9068310b36fed950940d251c4b798ffc58
2013-06-13 15:50:59 +00:00
drh
e1e2e9acd6 Make the MIN() and MAX() macros available in sqliteInt.h. Add TUNING
comments to the NGQP and adjust costs slightly.

FossilOrigin-Name: 3a72af2a95b04b8e195ef17cb3e9d9021a4f0915
2013-06-13 15:16:53 +00:00
drh
12ffbc7e69 Fix an off-by-one error in the WhereCost to integer conversion.
FossilOrigin-Name: b5ca80d924f8c6d31f036247ba6e20d234f4482e
2013-06-13 14:51:53 +00:00
drh
3b48e8c91a Activate the one-pass optimization. Update comments, especially the
descriptions of the various objects.

FossilOrigin-Name: e120c558a5bafc0f0d2cc12ee5c9d36e20cc642d
2013-06-12 20:18:16 +00:00
drh
95ed68df55 Bug fixes in the handling of virtual tables.
FossilOrigin-Name: 25c0f7292a20c0db6ef176966d9987f29c7d73e5
2013-06-12 17:55:50 +00:00
drh
37ca04880a Merge all changes from trunk.
FossilOrigin-Name: f2e15b1974e55373b5819e3b2326653f890f409f
2013-06-12 17:17:45 +00:00
drh
4fe425ad79 "make test" now passing.
FossilOrigin-Name: addd7f466d6ff55f82d907286650c26b06e9397b
2013-06-12 17:08:06 +00:00
drh
fd5874d23d Add the "queryplanner" test permutation. Continuing refinements to NGQP.
FossilOrigin-Name: 25e2cde105a19293bdb9c001b48624e5d7f8c4e5
2013-06-12 14:52:39 +00:00
drh
e217efc822 Continue refining the NGQP
FossilOrigin-Name: 40567fddd468d00295275af8df09a7a1785e684a
2013-06-12 03:48:41 +00:00
drh
4f402f26b1 Improved processing of DISTINCT.
FossilOrigin-Name: ba897100fed291d2025f68d09334f9985312298b
2013-06-11 18:59:38 +00:00
drh
8e23daf372 Fix the Parse.nQueryLoop state variable to work with NGQP.
FossilOrigin-Name: f1cac24f06b9c71cfa472fdcf2da4cd8689a7cc3
2013-06-11 13:30:04 +00:00
drh
8a4380d761 Fixes to EXPLAIN QUERY PLAN output. Change weights back to something closer
to what they are in legacy.  More test case fixes.

FossilOrigin-Name: 36373b85f9a97840aa06e24ae31c12fcfbae084e
2013-06-11 02:32:50 +00:00
drh
8636e9c55c Handle virtual tables correctly when using logarithmic costs. Fixes
to test cases.

FossilOrigin-Name: e612664aa2e24ed5e222be2c7fe16e210ac9bded
2013-06-11 01:50:08 +00:00
drh
5822d6feb2 Fix test cases for the new EXPLAIN QUERY PLAN format. Add the
wherecosttest tool.  Other fixes to logarithm cost.

FossilOrigin-Name: aa580e368e3c398b8377b80342dfdd906324c248
2013-06-10 23:30:09 +00:00
drh
c63367ef68 Fix some minor issues with logarithmic cost in NGQP.
FossilOrigin-Name: 69cf877283d362915edddf1822fbf7a9f86278b3
2013-06-10 20:46:50 +00:00
drh
b8a8e8a5d2 First attempt to store costs and row counts as a logarithm.
FossilOrigin-Name: 9e8109673c3a87e379f5a5a97a8b0d5a1afe853d
2013-06-10 19:12:39 +00:00
drh
3b75ffaaca Simplification and performance tweak to the high-speed NGQP bypass.
FossilOrigin-Name: 0f8a38ee54208d6a477aa2482cd277b4808450f0
2013-06-10 14:56:25 +00:00