-
Notifications
You must be signed in to change notification settings - Fork 493
Altermv tutorial #34854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: altermv-tutorial
Are you sure you want to change the base?
Altermv tutorial #34854
Conversation
| things like querying materialized views from different clusters, indexed vs. | ||
| non-indexed, and so on." | ||
|
|
||
| {{< if-released "v26.10" >}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FROM highest_bid_per_auction | ||
| WHERE end_time < mz_now(); | ||
| ``` | ||
| {{% include-example file="examples/create_materialized_view" example="example-create-materialized-view" %}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced this with the example from quickstart (with the modification of creating a view -> creating a materialized view).
|
|
||
| ## Details | ||
|
|
||
| ### Replacing a materialized view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - name: "syntax-apply-replacement" | ||
| code: | | ||
| ALTER MATERIALIZED VIEW <name> APPLY REPLACEMENT <replacement_name>; | ||
| ALTER MATERIALIZED VIEW <name> APPLY REPLACEMENT <replacement_view>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to view ... in case people thought we were renaming.
| the target materialized view. See [`CREATE REPLACEMENT MATERIALIZED VIEW | ||
| <replacement_view>...FOR <name>...`](/sql/create-materialized-view). | ||
|
|
||
| - name: "example-apply-replacement" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Materialize supports a two-step process for replacing materialized views | ||
| in-place, i.e., without recreating downstream objects: | ||
|
|
||
| 1. **Create a replacement**: Use `CREATE REPLACEMENT MATERIALIZED VIEW` to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since there's the guide being written, I condensed this.
https://preview.materialize.com/materialize/34854/sql/create-materialized-view/#use-case
| #### Restrictions | ||
| #### Query performance of replacement views | ||
|
|
||
| - The replacement must have the same schema as the target materialized view: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I incorporated this not quite as a restriction ... but more on how to run the command
| --- | ||
| You cannot run `ALTER MATERIALIZED VIEW ... APPLY REPLACEMENT` command within a | ||
| transaction block. Instead, the `ALTER MATERIALIZED VIEW ... APPLY REPLACEMENT` | ||
| command must be run outside of an explicit transaction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ... actually, given that we only allow:
- read-only transactions (for SELECT only txn or SUBSCRIBE-based txns)
- insert-only transactions
We might not actually need this .. because the list of things we don't allow in a transaction block is everything but the aforementioned bullet points.
| ``` | ||
|
|
||
| If the target view is behind, it is recommended to drop the replacement | ||
| view instead of having it run for an extended period, buffering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Is this something people can gauge by how far behind the target is? or is it just people check again after some time and see that it is still behind?
Q: Can people reduce the likelihood of the target being behind by applying the replacement view soon after it hydrates?
| If the replacement view is ahead of the target view, both the command and | ||
| the replacement view wait for the target view to catch up. During this | ||
| wait, the replacement view buffers any changes it receives from its | ||
| inputs, which, depending on the amount to buffer, could cause the cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: If someone runs the command before checking and it hangs, should we tell people to break out of it?
Wanted to get a pulse on the changes before tweaking the guide a bit.
For ease of review, added a patch to fake the release of v26.10 (2d89321) which will be reverted before merging [hence, converted to draft]