vitess
vitess copied to clipboard
Experimental POC: Materialized Views
Description
This PR is an experiment in materializing joined tables to determine if it can be reliably built, estimate the complexity of implementing it with the current VReplication framework, and identify inherent limitations.
Current Implementation
User View
- Utilize Materialize with a single table-setting where the query is a view. The view should include a directive like select /*vt+ view=orders_view */.
- The target and source keyspace must be the same.
- The filter generated by Materialize has the materialized view's table name as the match, and the filter is the view query.
- The view must contain the primary key columns for each participating table, each part of an index. This ensures that updates and deletes to lookup tables, which result in bulk DMLs, are more efficient.
- Initially, only integer primary keys are supported until we better understand the consequences of bulk DMLs and supporting views.
Todos
- [x] Remove hardcoded column name for base table!
- [x] Handle case where column names are repeated across joined tables
- [ ] More unit tests in vplayer for join plans
- [ ] More unit tests in vstreamer for join plans
- [ ] Validation for parameters and view query: all PKs to be specified, required directive,
- [ ] Remove excess logs
- [ ] Allow target keyspace to be different: in that case we need to also replicate the lookup tables since future inserts will otherwise fail, as we exec the view query to get the new row whenever there is an insert into the base row.!
Related Issue(s)
RFC todo
Checklist
- [ ] "Backport to:" labels have been added if this change should be back-ported to release branches
- [ ] If this change is to be back-ported to previous releases, a justification is included in the PR description
- [ ] Tests were added or are not required
- [ ] Did the new or modified tests pass consistently locally and on CI?
- [ ] Documentation was added or is not required