Jussi Saurio
d2b1be8af7
Merge 'optimizer: fix order by removal logic' from Jussi Saurio
...
1. `group_by_contains_all` was incorrect - it was not checking that all
order by columns are in group by; it was instead checking that all group
by columns are in order by, which is absolutely incorrect for the
intended purpose.
2. remove ORDER BY clause if GROUP BY clause can sort the rows in the
same way.
Test failures are not related
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com >
Closes #1511
2025-05-19 11:29:17 +03:00
Jussi Saurio
b7b4f6a390
Merge 'Mark WHERE terms as consumed instead of deleting them' from Jussi Saurio
...
We've run into trouble in multiple places due to the fact that we delete
terms from the where clause (e.g. when a constant condition is removed,
or the term becomes part of an index seek key).
A simpler solution is to add a flag indicating that the term is consumed
(used), so that it is not translated in the main loop anymore when WHERE
clause terms are evaluated.
note: CI failures are unrelated
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com >
Closes #1477
2025-05-19 11:28:09 +03:00
pedrocarlo
7f081c1ac9
remove transmute. Just iterate over columns. No need for unsafe
2025-05-18 12:32:49 -03:00
pedrocarlo
0e6ef1f478
removed some clone, simplified slightly logic + also inserted the column name of the current column we are iterating, not only the last column contained in PrimaryKeyDefinitionType::Simple
2025-05-17 15:32:58 -03:00
pedrocarlo
166dc2184e
fix autoindex creation not detecting if column existed in created table declaration using transmute to avoid cloning
2025-05-17 12:58:00 -03:00
Jussi Saurio
93d88527c3
optimizer: remove order by if group by already sorts the result properly
2025-05-17 17:42:52 +03:00
Jussi Saurio
ce8b2722cf
optimizer: fix incorrect logic in group_by_contains_all
2025-05-17 17:28:29 +03:00
Jussi Saurio
d584a1879b
Mark WHERE terms as consumed instead of deleting them
...
We've run into trouble in multiple places due to the fact that
we delete terms from the where clause (e.g. when a constant condition
is removed, or the term becomes part of an index seek key).
A simpler solution is to add a flag indicating that the term is
consumed (used), so that it is not translated in the main loop
anymore when WHERE clause terms are evaluated.
2025-05-17 15:44:12 +03:00
Pere Diaz Bou
74328f2617
fix allocation of indices BTreeCreate registers
...
For some reason we always allocated one more index than required when we
had `total_indices>1`.
2025-05-16 10:37:04 +02:00
Pere Diaz Bou
ff524d037d
fix autoindex of primary key marked as unique
...
Primary keys that are marked as unique constraint, do not need to have
separate indexes, one is enough. In the case primary key is integer,
therefore rowid alias, we still need an index to satisfy unique
constraint.
2025-05-16 10:37:04 +02:00
Pekka Enberg
e3f71259d8
Rename OwnedValue -> Value
...
We have not had enough merge conflicts for a while so let's do a
tree-wide rename.
2025-05-15 09:59:46 +03:00
pedrocarlo
72cc0fcdcb
fixes and comments
2025-05-14 13:30:39 -03:00
pedrocarlo
b2615d7739
add CursorValidState and only save context in delete when rebalancing
2025-05-14 13:30:39 -03:00
pedrocarlo
814508981c
fixing more rebase issues and cleaning up code. Save cursor context when calling delete for later use when needed
2025-05-14 13:30:39 -03:00
pedrocarlo
c69f503eac
rebase adjustments
2025-05-14 13:30:39 -03:00
pedrocarlo
05f4ca28cc
btree rewind and next fix. Keep track of rowids seen to avoid infinite loop
2025-05-14 13:30:39 -03:00
pedrocarlo
6588004f80
fix incorrectly detecting if user provided row_id_alias to set clause
2025-05-14 13:30:39 -03:00
pedrocarlo
482634b598
adjust null opcode emission based in rowid_alias
2025-05-14 13:30:39 -03:00
pedrocarlo
758dfff2fe
modified tests as we do not have rollback yet. Also correctly raise a contraint error on primary keys only
2025-05-14 13:30:39 -03:00
pedrocarlo
3aaf4206b7
altered constraint tests to create bad update statements. Tests caught a bug where I was copying the wrong values from the registers
2025-05-14 13:30:39 -03:00
pedrocarlo
cf7f60b8f5
changed from resolve_label to preassign_label
2025-05-14 13:30:39 -03:00
pedrocarlo
6457d7675a
instruction emitted should be correct, but having an infinite loop bug
2025-05-14 13:30:39 -03:00
pedrocarlo
60a99851f8
emit NoConflict and Halt. Already detects unique constraints
2025-05-14 13:30:39 -03:00
pedrocarlo
5f2216cf8e
modify explain for MakeRecord to show index name
2025-05-14 13:30:39 -03:00
pedrocarlo
9aebfa7b5d
open cursors for write only once
2025-05-14 13:30:39 -03:00
pedrocarlo
5bae32fe3f
modified OpenWrite to include index or table name in explain
2025-05-14 13:30:39 -03:00
pedrocarlo
e7fa023c26
Adding indexes to the update plan
2025-05-14 13:30:39 -03:00
pedrocarlo
4dc1431428
handling edge case when passing duplicate a multi-column unique index
2025-05-14 11:46:24 -03:00
pedrocarlo
3526a206e4
support Unique properly by creating a vec of auto indices
2025-05-14 11:34:39 -03:00
pedrocarlo
bb158a5433
add unique field to Column
2025-05-14 11:34:11 -03:00
pedrocarlo
002acbb9dc
add check for unique contraint in auto index creation
2025-05-14 11:34:11 -03:00
Jussi Saurio
176d9bd3c7
Prune bad plans earlier to avoid allocating useless JoinN structs
2025-05-14 09:42:26 +03:00
Jussi Saurio
eb983c88c6
reserve capacity for memo hashmap entries
2025-05-14 09:42:26 +03:00
Jussi Saurio
5e5788bdfe
Reduce allocations
2025-05-14 09:42:26 +03:00
Jussi Saurio
d2fa91e984
avoid growing vec
2025-05-14 09:42:26 +03:00
Jussi Saurio
625cf005fd
Add some utilities to constraint related structs
2025-05-14 09:42:26 +03:00
Jussi Saurio
71ab3d57d8
constraints.rs: more comments
2025-05-14 09:42:26 +03:00
Jussi Saurio
5386859b44
as_binary-components: simplify
2025-05-14 09:42:26 +03:00
Jussi Saurio
1d465e6d94
Remove unnecessary method
2025-05-14 09:42:26 +03:00
Jussi Saurio
9d50446ffb
AccessMethod: simplify - get rid of AccessMethodKind as it can be derived
2025-05-14 09:42:26 +03:00
Jussi Saurio
12a2c2b9ad
Add more documentation to OPTIMIZER.MD
2025-05-14 09:42:26 +03:00
Jussi Saurio
fe628e221a
plan_satisfies_order_target(): simplify
2025-05-14 09:42:26 +03:00
Jussi Saurio
4dde356d97
AccessMethod: simplify
2025-05-14 09:42:26 +03:00
Jussi Saurio
a90358f669
TableMask: comments
2025-05-14 09:42:26 +03:00
Jussi Saurio
f12eb25962
cost.rs: simplify cost estimation
2025-05-14 09:42:26 +03:00
Jussi Saurio
4f07c808b2
Fix bug with constraint ordering introduced by refactor
2025-05-14 09:42:26 +03:00
Jussi Saurio
52b28d3099
rename use_indexes to optimize_table_access
2025-05-14 09:42:26 +03:00
Jussi Saurio
d8218483a2
use_indexes: comments
2025-05-14 09:42:26 +03:00
Jussi Saurio
e53ab385d7
order.rs: comments
2025-05-14 09:42:26 +03:00
Jussi Saurio
ff8e187eda
find_best_access_method_for_join_order: comments
2025-05-14 09:42:26 +03:00