-
Notifications
You must be signed in to change notification settings - Fork 5.5k
docs(analyzer): Add materialized view documentation #26572
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ================== | ||
| Materialized Views | ||
| ================== | ||
|
|
||
| Introduction | ||
| ------------ | ||
|
|
||
| A materialized view stores the results of a query physically, unlike regular views which are virtual. | ||
| Queries can read pre-computed results instead of re-executing the underlying query against base tables. | ||
|
|
||
| Materialized views improve performance for expensive queries by calculating results once during | ||
| refresh rather than on every query. Common use cases include aggregations, joins, and filtered | ||
| subsets of large tables. | ||
|
|
||
| .. warning:: | ||
|
|
||
| Materialized views are experimental. The SPI and behavior may change in future releases. | ||
| Use at your own risk in production environments. | ||
|
|
||
| To enable materialized views, set :ref:`admin/properties:\`\`experimental.legacy-materialized-views\`\`` = ``false`` | ||
| in your configuration properties, or use ``SET SESSION legacy_materialized_views = false``. | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
||
| :doc:`/sql/create-materialized-view`, :doc:`/sql/drop-materialized-view`, | ||
| :doc:`/sql/refresh-materialized-view`, :doc:`/sql/show-create-materialized-view` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
presto-docs/src/main/sphinx/sql/create-materialized-view.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ======================== | ||
| CREATE MATERIALIZED VIEW | ||
| ======================== | ||
|
|
||
| .. warning:: | ||
|
|
||
| Materialized views are experimental. The SPI and behavior may change in future releases. | ||
|
|
||
| To enable, set :ref:`admin/properties:\`\`experimental.legacy-materialized-views\`\`` = ``false`` | ||
| in configuration properties. | ||
|
|
||
| Synopsis | ||
| -------- | ||
|
|
||
| .. code-block:: none | ||
|
|
||
| CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] view_name | ||
| [ COMMENT 'string' ] | ||
| [ WITH ( property_name = expression [, ...] ) ] | ||
| AS query | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| Create a new materialized view of a :doc:`select` query. The materialized view physically stores | ||
| the query results, unlike regular views which are virtual. Queries can read pre-computed results | ||
| instead of re-executing the underlying query. | ||
|
|
||
| The optional ``IF NOT EXISTS`` clause causes the materialized view to be created only if it does | ||
| not already exist. | ||
|
|
||
| The optional ``COMMENT`` clause stores a description of the materialized view in the metastore. | ||
|
|
||
| The optional ``WITH`` clause specifies connector-specific properties. Connector properties vary by | ||
| connector implementation. Consult connector documentation for supported properties. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| Create a materialized view with daily aggregations:: | ||
|
|
||
| CREATE MATERIALIZED VIEW daily_sales 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 | ||
|
|
||
|
|
||
| Create a materialized view with connector properties:: | ||
|
|
||
| CREATE MATERIALIZED VIEW partitioned_sales | ||
| WITH ( | ||
| partitioned_by = ARRAY['year', 'month'] | ||
| ) | ||
| AS | ||
| SELECT year(order_date) AS year, | ||
| month(order_date) AS month, | ||
| SUM(amount) AS total_sales | ||
| FROM orders | ||
| GROUP BY year(order_date), month(order_date) | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
||
| :doc:`drop-materialized-view`, :doc:`refresh-materialized-view`, | ||
| :doc:`show-create-materialized-view`, :doc:`/admin/materialized-views` |
42 changes: 42 additions & 0 deletions
42
presto-docs/src/main/sphinx/sql/drop-materialized-view.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| ===================== | ||
| DROP MATERIALIZED VIEW | ||
| ===================== | ||
|
|
||
| .. warning:: | ||
|
|
||
| Materialized views are experimental. The SPI and behavior may change in future releases. | ||
|
|
||
| To enable, set :ref:`admin/properties:\`\`experimental.legacy-materialized-views\`\`` = ``false`` | ||
| in configuration properties. | ||
|
|
||
| Synopsis | ||
| -------- | ||
|
|
||
| .. code-block:: none | ||
|
|
||
| DROP MATERIALIZED VIEW [ IF EXISTS ] view_name | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| Drop an existing materialized view and delete its stored data. | ||
|
|
||
| The optional ``IF EXISTS`` clause causes the statement to succeed even if the materialized view | ||
| does not exist. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| Drop the materialized view ``daily_sales``:: | ||
|
|
||
| DROP MATERIALIZED VIEW daily_sales | ||
|
|
||
| Drop the materialized view if it exists:: | ||
|
|
||
| DROP MATERIALIZED VIEW IF EXISTS daily_sales | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
||
| :doc:`create-materialized-view`, :doc:`refresh-materialized-view`, | ||
| :doc:`show-create-materialized-view`, :doc:`/admin/materialized-views` |
36 changes: 36 additions & 0 deletions
36
presto-docs/src/main/sphinx/sql/refresh-materialized-view.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| ======================== | ||
| REFRESH MATERIALIZED VIEW | ||
| ======================== | ||
|
|
||
| .. warning:: | ||
|
|
||
| Materialized views are experimental. The SPI and behavior may change in future releases. | ||
|
|
||
| To enable, set :ref:`admin/properties:\`\`experimental.legacy-materialized-views\`\`` = ``false`` | ||
| in configuration properties. | ||
|
|
||
| Synopsis | ||
| -------- | ||
|
|
||
| .. code-block:: none | ||
|
|
||
| REFRESH MATERIALIZED VIEW view_name | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| Refresh the data stored in a materialized view by re-executing the view query against the base | ||
| tables. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| Refresh a materialized view:: | ||
|
|
||
| REFRESH MATERIALIZED VIEW daily_sales | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
||
| :doc:`create-materialized-view`, :doc:`drop-materialized-view`, | ||
| :doc:`show-create-materialized-view`, :doc:`/admin/materialized-views` |
35 changes: 35 additions & 0 deletions
35
presto-docs/src/main/sphinx/sql/show-create-materialized-view.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| ============================ | ||
| SHOW CREATE MATERIALIZED VIEW | ||
| ============================ | ||
|
|
||
| .. warning:: | ||
|
|
||
| Materialized views are experimental. The SPI and behavior may change in future releases. | ||
|
|
||
| To enable, set :ref:`admin/properties:\`\`experimental.legacy-materialized-views\`\`` = ``false`` | ||
| in configuration properties. | ||
|
|
||
| Synopsis | ||
| -------- | ||
|
|
||
| .. code-block:: none | ||
|
|
||
| SHOW CREATE MATERIALIZED VIEW view_name | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| Show the SQL statement that creates the specified materialized view. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| Show the SQL for the ``daily_sales`` materialized view:: | ||
|
|
||
| SHOW CREATE MATERIALIZED VIEW daily_sales | ||
|
|
||
| See Also | ||
| -------- | ||
|
|
||
| :doc:`create-materialized-view`, :doc:`drop-materialized-view`, | ||
| :doc:`refresh-materialized-view`, :doc:`/admin/materialized-views` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.