449b34571e
Enable the EXISTS-to-JOIN optimization if the outer query has no
...
FROM clause.
FossilOrigin-Name: 1b9b124f9a35ebd1ac4ea70ef1ee08a4c82c11da690d4164f6b785a6fd9730d9
2025-07-08 17:28:09 +00:00
8c8443a38a
Small performance optimization in the resolver.
...
FossilOrigin-Name: 840646df0696706bd4dd7a04dfc8b16ad80c24cbcbc57a22c9e65a93cc17af2b
2025-07-07 19:03:50 +00:00
44a03671c4
Merge the latest trunk enhancements and fixes into the empty-table-optimizations branch.
...
FossilOrigin-Name: f15cdf07573c05276a13885d74bae21a93544766344f19ef939b7a69edd1073b
2025-07-07 18:35:51 +00:00
0a5508aeb4
Rework the fix to the problem described by
...
[forum:/forumpost/b9647a113b465950|forum post b9647a113b] so that it
provides a more complete fix that covers cases that were not resolved by
the original fix, and so that it does not cause performance regressions.
FossilOrigin-Name: 28db0d152d90fb5e62d03ea5caceabe8901be98522aef3dc2b54564fbc35355d
2025-07-07 16:19:44 +00:00
4fe1ac8fe1
Simplifications to the row-value IN operator logic. Do not let the query
...
planner accept a WhereLoop for a row-value IN operator that uses the same
index column more than once.
FossilOrigin-Name: d2adf61f21a3ce901a2b08199ad0de191e88ef16e097c5f7a75c95ad958eff12
2025-07-07 15:40:53 +00:00
24d290e7b0
Work around the Emscripten 4.10 regression described in [ https://github.com/emscripten-core/emscripten/issues/24656 | Emscripten ticket #24656 ]. Problem reported off-list by BrickViking.
...
FossilOrigin-Name: c385475b250f3364507a95c5832137098a9bb7c7fc12ab3bb116e1fad7bb7645
2025-07-07 12:11:26 +00:00
8504d37b99
Avoid invoking the preupdate hook from within sqlite3_blob_write() if the cursor is already invalid.
...
FossilOrigin-Name: 9f335b9a4e9e761a0c6afd6dc69665a24506141bde88530bf59fcbdf957ae881
2025-07-07 11:37:55 +00:00
4aacd1ef8e
Back out the fix at [ba7d5bad32ad6aac] because it does not always work and because
...
it causes a performance regression. Add new test cases for row-value lookups of
indexes that contain redundant columns, three of which are currently failing. This
branch is seeking an improved solution to the redundant index column problem for
row-value lookups.
FossilOrigin-Name: ad8ddcefab5cc526b1cd77731e00939c672e61ca83350d28961b67635d20da03
2025-07-07 10:54:00 +00:00
0840460689
Fix parser error introduced by [325e547a2195571e]. See
...
[forum:/forumpost/095dbfc06e5b1f7e|forum post 095dbfc06e5].
FossilOrigin-Name: 4eefab44941fc6e17742fa49c8734e7f00a2177d82bc572e596228add53aad39
2025-07-07 02:18:27 +00:00
c701d17366
Improvements to the EXPLAIN QUERY PLAN output for EXISTS-to-JOIN.
...
FossilOrigin-Name: 6b1ecbaa2ee405be040901dceac45d027d35c313622748ba4dbbd404e297a7fa
2025-07-06 01:19:09 +00:00
8bc112e3e4
Enhance the EXISTS-to-JOIN optimization so that it works on EXISTS subqueries
...
that do not have a WHERE clause, and so that it works on nested EXISTS
subqueries.
FossilOrigin-Name: c1d5295724f9cf7f49e0786d28016eff2d268a2b670f934d24c76787626089db
2025-07-05 23:33:21 +00:00
27408ab9c9
Add 'reconfigure' target to Makefile.in to re-run the configure script with the same flags it was generated with.
...
FossilOrigin-Name: c60907e77b32824aaaf024d299cdaf161b5f64fc927ffe5d5455eeb5754e6b01
2025-07-04 18:32:18 +00:00
d9eae6b75a
Propagate the -ldl and -lpthread flags, if needed, into sqlite3.pc, per request in [forum:44a58c807353162f | forum post 44a58c807353162f].
...
FossilOrigin-Name: 64f5f14322349b47451b8cac03bf8cd6f1ae45a8822e7f1ddee3d0b265047501
2025-07-04 17:20:37 +00:00
45bc9b9f97
Merge fixes from trunk into the empty-table-optimizations branch
...
FossilOrigin-Name: 6f98b16d210a9f5b6ca4b4599e3dab3263eddbae7c70ddbcabf988f4a1014e8b
2025-07-04 14:24:18 +00:00
e33ea17d24
Fix harmless compiler warnings.
...
FossilOrigin-Name: 13af4acebe09b047756c22b800136cffaba532e7fcaa448a4edf4fedb94e9bbc
2025-07-04 12:25:24 +00:00
a12e92d2f7
Remove an ALWAYS() added by [960a8e6fc91f4] that turns out to be false
...
in some cases of malformed SQL.
FossilOrigin-Name: cc8171461bf35f584888a24b844c8b79ad30155b19b61161e9f3abc276e8aae5
2025-07-04 11:48:11 +00:00
478dfc7e74
Do not allow the EXISTS-to-JOIN optimization if the EXISTS clause is based
...
on a view, since that view might expand into a join.
FossilOrigin-Name: 872c41feddafcc21a02f1229ce017ceea9f8e309a4dd5b6e323477d67f975947
2025-07-04 11:06:34 +00:00
1b62720fa8
Improve the early-termination optimization so that it works in queries
...
which use the LIKE optimization in the outer loop.
FossilOrigin-Name: b4e4d148243cfcb09aa0aaca30e83812b42e2780073e55c0e8c6e3da16243dfc
2025-07-04 10:26:55 +00:00
1e3a862b79
Merge the latest trunk fixes and enhancements into the empty-table-optimizations branch
...
FossilOrigin-Name: d4f47e04f5880e99a53089e2dd5cde64a7ea44f059d9906b5d11324896546714
2025-07-03 20:51:08 +00:00
bd05edd98f
Fix a few cases where LIMIT clauses that were part of scalar sub-queries on virtual tables were not being passed to xBestIndex methods correctly.
...
FossilOrigin-Name: 960a8e6fc91f47add3a089dc6cef013109deadf809994c5149ad3bdfb3884de0
2025-07-03 16:05:41 +00:00
a24a397b8b
Improvements to sqlite3_vtab_rhs_value() logging in the
...
ext/misc/vtablog.c extension.
FossilOrigin-Name: 25131ee84f53dab1191e02c19cefd256aed2828c7edea325fcc0ba3b0a668583
2025-07-03 15:50:18 +00:00
0e6e05d4d5
Make the value of an explicit LIMIT clause on a scalar sub-query available to xBestIndex for simple "LIMIT 0" and "LIMIT 1" queries.
...
FossilOrigin-Name: 33b6a63caafccc61b3193714911cd8b5dd9b7f1798054b8c7845b23688d531f2
2025-07-03 15:32:27 +00:00
c525e6e817
Make handling of LIMIT clauses in correlated sub-queries on virtual tables more efficient.
...
FossilOrigin-Name: 7214cb2a5b35190a06a1040cd4c54f325d347f8d8e36a07fd76c0a421e266522
2025-07-03 14:28:47 +00:00
1ff6f19d8b
Enhancements to the xBestIndex output from the ext/misc/vtablog.c
...
extension.
FossilOrigin-Name: 8b31acc0b18f38eb4af6efebd1ea25cd65a146651101579aee20afd9ec6dc2de
2025-07-03 14:10:03 +00:00
bfb4993364
Fix an uninitialized variable added yesterday by [d27d34fb746280e7].
...
This problem was discovered overnight by
[https://github.com/google/oss-fuzz |OSSFuzz].
FossilOrigin-Name: 6db4703f1178fc808f3a75c355fb6638fb12c88f6e1ce7f579e200ced8089114
2025-07-03 11:52:17 +00:00
debc8f7bb7
Minor tweaks to the exists-to-join optimization.
...
FossilOrigin-Name: 9cb600ad576c68647ed943a0773019312c5f01c9c1ca9ff0bf1214b03a531b48
2025-07-03 00:17:27 +00:00
aa54d7a0ca
Merge in the exists-to-join optimization that has been modified
...
to relax the requirement of having an indexed join constraint.
FossilOrigin-Name: 1c1aef2b7feae29066d0330699ab634ef41f5b60cdcd479a60cb1a5409553138
2025-07-02 20:46:02 +00:00
eb27359e5e
Fix VDBE coverage
...
FossilOrigin-Name: ff593a16d61cc5c588d1737deb822abb90b1759475a4cabfcf608978b1191487
2025-07-02 17:43:59 +00:00
33f3273705
Early exit if one of the inner loops of a 3-way or larger join is an
...
empty table.
FossilOrigin-Name: eaad6ac707a5960d9518d4049b7b1759e7512727ce87be3c402408144bda0a97
2025-07-02 14:53:48 +00:00
216676664d
If the LHS for an EXCEPT or INTERSECT operator is empty, skip over the
...
computation of the RHS.
FossilOrigin-Name: 13f096ae8a850a05d4a8684561066f11693ee66289e6568c44ef32822cca06f6
2025-07-02 13:19:24 +00:00
6245e5a46b
Improve the bytecode for joins such that it exits earlier if it determines
...
that no output is possible.
FossilOrigin-Name: 2d2b61cba44a756a3a41ef5c95bbb0c0b7111f4b679c578fec9bd0b214cca367
2025-07-02 11:47:54 +00:00
caf0473652
Ensure that Expr.op2 values for TK_AGG_FUNCTION nodes are adjusted when
...
query flattening.
FossilOrigin-Name: d27d34fb746280e7e81335db4e195914b15403ef0da7b2955550553dd78fbe9a
2025-07-02 02:03:43 +00:00
2427ce16d9
Improved comments on bytecode used to implement aggregate queries, to aid
...
in debugging.
FossilOrigin-Name: a1a8b85cdba64a17dcdcd4e6b42b872957cec2dc05b0ac34dfcd82f59344034b
2025-07-01 23:17:36 +00:00
46bfcc1a21
Improved byte-code comments for the short-circuit optimization of
...
[0083d5169a46104a], to aid in debugging.
FossilOrigin-Name: 113f9d10e347eeaa893ff8b47a461009e0b12589374b93cf3e0bddd19c702dea
2025-07-01 20:32:45 +00:00
5e71497404
Cache and reuse virtual table cursors in the bytecode engine.
...
FossilOrigin-Name: 2d187d4232d750cb1840f1d89c8aed65962cb0883c1d7f91c554b451e475c514
2025-07-01 17:36:55 +00:00
526399b0fd
Avoid an assert() failure in fts5 that may occur when processing corrupt records.
...
FossilOrigin-Name: 8afd6ca85724a69970181042d6aac53742ea2b76ded5966b2541c3afe1121fb9
2025-07-01 16:21:47 +00:00
e1910ed1d2
Merge trunk fixes into the empty-table-optimizations branch.
...
FossilOrigin-Name: 63306e447efb3ac17e789a331ed3bb65459eb8b79d66e9c185ba3bd852f34ce3
2025-07-01 15:13:37 +00:00
d82c6a2cf7
When attempting to optimize "expr AND false" to "false" and
...
"expr IN ()" to "false", take care not to delete aggregate functions
in the "expr" as doing so can change the meaning of the query.
See [forum:/forumpost/f4878de3e7dd4764|forum thread f4878de3e7].
FossilOrigin-Name: 77397bd67d918db57d5ac545d6d963194806fdabcdaa8f822b6b09e4cfe8b715
2025-07-01 12:43:13 +00:00
3d21dcc924
More aggressive optimization of addrHalt for RIGHT JOIN.
...
FossilOrigin-Name: 5e51d1c0dfcafef9e71c99de3f626dee157c935724b84c6e0c630299a880446f
2025-06-30 21:07:08 +00:00
ba56f7020d
Compute WhereLevel.addrBrk and .addrHalt early so that those labels can be
...
used to abort loops early. Use this to improve performance on two more
of the cases described by [forum:/forumpost/52651713ac|forum post 52651713ac].
FossilOrigin-Name: 6fc0b9ac23be6840542982de4bb282ebca1db8b5ab3baefdde95a997c1506e81
2025-06-30 20:19:19 +00:00
99f1aa03fb
Strive to skip the evaluation of scalar subqueries that are part of a
...
larger expression if the result from the scalar subquery does not change the
result of the overall expression.
FossilOrigin-Name: 0083d5169a46104a25355bdd9d5a2f4027b049191ebda571dd228477ec217296
2025-06-30 16:41:40 +00:00
280559b446
For all binary operators, try to avoid computing subquery operands if the
...
other operand is NULL.
FossilOrigin-Name: d86eb16283c4b573c506d4faa422d5d9aeb6abc279d8e6a8e2104737162d417f
2025-06-30 12:14:47 +00:00
e2e81e6983
Slightly smaller and faster version of the previous check-in.
...
FossilOrigin-Name: f6e6fd02f4ad49c390a2d3c9626d57f9b2fff1f67eb361b30074cc1f5121810e
2025-06-30 11:04:55 +00:00
b8c81790b2
Minor API doc typo fixes from brickviking.
...
FossilOrigin-Name: b48d95191662e09659b5b55ae65cd462c9e1700c4f92dd9d40b59548f0797c02
2025-06-30 11:00:59 +00:00
e24f20a4f5
Factor out the code that tries to avoid evaluating subquery operands if the
...
other operand is NULL into a subroutine, so that it can be more easily reused
by other parts of the code generator.
FossilOrigin-Name: 3c6c71bcea16443b82234414137dfa1b59e2ee8fe5097906c738fc1228fec4e6
2025-06-30 10:30:47 +00:00
f0991c416b
Minor API doc typo fixes from brickviking.
...
FossilOrigin-Name: c7cf9dcb69ce558ba6b81b2787f92ed7383e37f08b199faeb14f7adb4e494532
2025-06-29 07:32:20 +00:00
311d73efc2
Improve the bytecode generated for comparisons so that if one operand is
...
a subquery and the other operand evaluates to NULL, the subquery operand
is not even computed. This fixes 5 of the 12 slow queries described
in [forum:/forumpost/52651713ac|forum post 52651713ac].
FossilOrigin-Name: f147bc04776ac0056412f69dfc518016c0d5b4e9d964664e3d88f595fb29dbe0
2025-06-28 17:59:15 +00:00
c52e9d97d4
Raise an error right away if the number of aggregate terms in a query
...
exceeds the maximum number of columns.
FossilOrigin-Name: 5508b56fd24016c13981ec280ecdd833007c9d8dd595edb295b984c2b487b5c8
2025-06-27 19:02:21 +00:00
fbf1c0526e
API doc typo fixes and closing DD element tags from brickviking.
...
FossilOrigin-Name: c9ddd15b0197e6e5c5a74581d94cf986523514ffdb28c66ba18de9a22aec97e9
2025-06-27 12:46:50 +00:00
e77e589a35
Work around an apparent GCC UBSAN bug. See
...
[forum:/forumpost/1d7c25d4a2d6f5e2|forum thread 1d7c25d4a2d] for details.
FossilOrigin-Name: 23056532e51abcff486e38a3319545e6663b4a855abe1bc443e2cd7e0473748c
2025-06-26 18:57:20 +00:00