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
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
pedrocarlo
4dc1431428
handling edge case when passing duplicate a multi-column unique index
2025-05-14 11:46:24 -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
Jussi Saurio
3442e4981d
remove some unnecessary parameters
2025-05-14 09:42:26 +03:00
Jussi Saurio
c18bb3cd14
rename
2025-05-14 09:42:26 +03:00
Jussi Saurio
15b32f7e57
constraints.rs: more comments
2025-05-14 09:42:26 +03:00
Jussi Saurio
c782616180
Refactor constraints so that WHERE clause is not needed in join reordering phase
2025-05-14 09:42:26 +03:00
Jussi Saurio
6aa5b01a7b
Add note about optimizer directory structure
2025-05-14 09:42:26 +03:00
Jussi Saurio
bd875e3876
optimizer module split
2025-05-14 09:42:26 +03:00
Jussi Saurio
ec45a92bac
move optimizer to its own directory
2025-05-14 09:42:26 +03:00