docs: Add more details to the materialized view documentation#27465
docs: Add more details to the materialized view documentation#27465bibith4 wants to merge 1 commit intoprestodb:masterfrom
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideExpands and clarifies the documentation for materialized views, including admin guidance, configuration details, and SQL syntax/usage for creating and refreshing materialized views. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
| +=====================+=====================+=====================+=====================+==============================+ | ||
| | USE_VIEW_QUERY | No | Yes | No (for queries) | Always fresh, MV ignored | | ||
| +---------------------+---------------------+---------------------+---------------------+------------------------------+ | ||
| | USE_STITCHING | Partial | Yes | No (for queries) | Hybrid result | |
There was a problem hiding this comment.
What does hybrid result mean?
| SET SESSION materialized_view_skip_storage = 'USE_STITCHING'; | ||
|
|
||
|
|
||
| Behavior Summary |
There was a problem hiding this comment.
This table doesn't seem very useful beyond the doc above, let's just remove it.
There was a problem hiding this comment.
@tdcmeehan I have removed the Table. Please check
| Create a materialized view with staleness configuration:: | ||
|
|
||
| ``staleness_window - How long stale data is acceptable`` | ||
|
|
||
| ``USE_VIEW_QUERY`` | ||
|
|
||
| CREATE MATERIALIZED VIEW daily_sales | ||
| WITH (stale_read_behavior = 'USE_VIEW_QUERY', | ||
| staleness_window = '1h' | ||
| ) AS | ||
| SELECT date_trunc('day', order_date) AS day, | ||
| region, | ||
| SUM(amount) AS total_sales, | ||
| COUNT(*) AS order_count | ||
| FROM orders | ||
| GROUP BY date_trunc('day', order_date), region | ||
|
|
||
| ``FAIL`` | ||
|
|
||
| CREATE MATERIALIZED VIEW daily_sales | ||
| WITH (stale_read_behavior = 'FAIL', | ||
| staleness_window = '30m' | ||
| ) AS | ||
| SELECT date_trunc('day', order_date) AS day, | ||
| region, | ||
| SUM(amount) AS total_sales, | ||
| COUNT(*) AS order_count | ||
| FROM orders | ||
| GROUP BY date_trunc('day', order_date), region | ||
|
|
||
| ``USE_STITCHING`` | ||
|
|
||
| CREATE MATERIALIZED VIEW daily_sales | ||
| WITH (stale_read_behavior = 'USE_STITCHING', | ||
| staleness_window = '1h' | ||
| ) AS | ||
| SELECT date_trunc('day', order_date) AS day, | ||
| region, | ||
| SUM(amount) AS total_sales, | ||
| COUNT(*) AS order_count | ||
| FROM orders | ||
| GROUP BY date_trunc('day', order_date), region | ||
|
|
||
| ``No staleness window(always stale after source changes)`` | ||
|
|
||
| CREATE MATERIALIZED VIEW daily_sales | ||
| WITH (stale_read_behavior = 'FAIL' | ||
| ) AS | ||
| SELECT date_trunc('day', order_date) AS day, | ||
| region, | ||
| SUM(amount) AS total_sales, | ||
| COUNT(*) AS order_count | ||
| FROM orders | ||
| GROUP BY date_trunc('day', order_date), region |
There was a problem hiding this comment.
Can we just have one example? I think it's clear that there's a default value if none are provided, and that the value can be parameterized.
There was a problem hiding this comment.
@tdcmeehan Updated to provide only one example. Please check
steveburnett
left a comment
There was a problem hiding this comment.
Thank you for the documentation! A couple of nits.
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 52ad58a...c99d493. No notifications. |
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the update! Just one question.
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the update! Just a nit of phrasing.
steveburnett
left a comment
There was a problem hiding this comment.
LGTM! (docs)
Pull updated branch, new local doc build, looks good. Thank you!
Description
Updated the materialized view documentation to incorporate supporting configurations and relevant examples.
Motivation and Context
To ensure consistent understanding and usage of materialized views
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Summary by Sourcery
Expand and clarify documentation around materialized views, including their creation and refresh behavior.
Documentation: