Skip to content

Conversation

@kay-kim
Copy link
Contributor

@kay-kim kay-kim commented Jan 28, 2026

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]

@kay-kim kay-kim requested a review from a team as a code owner January 28, 2026 23:53
@kay-kim kay-kim marked this pull request as draft January 28, 2026 23:53
@kay-kim kay-kim requested review from maheshwarip and teskje January 29, 2026 00:04
things like querying materialized views from different clusters, indexed vs.
non-indexed, and so on."

{{< if-released "v26.10" >}}
Copy link
Contributor Author

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" %}}
Copy link
Contributor Author

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
Copy link
Contributor Author

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>;
Copy link
Contributor Author

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"
Copy link
Contributor Author

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
Copy link
Contributor Author

@kay-kim kay-kim Jan 29, 2026

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:
Copy link
Contributor Author

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

https://preview.materialize.com/materialize/34854/sql/create-materialized-view/#creating-replacement-materialized-views

---
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.
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant