Managing materialized views in a database
A materialized view is a database object that persists the results of a query to disk. In Amazon Redshift, materialized views allow frequently used complex queries to be stored as separate database objects, allowing you to access these database objects directly, and enabling faster query responses.
Employing materialized views is a common approach to powering repeatable queries in a business intelligence (BI) dashboard, and avoids expensive computation each time. Furthermore, materialized views allow an incremental refresh of the results, using the underlying table data. In this recipe, we will create a materialized view to query the tables and also to persist the results for a faster fetch.
Getting ready
To complete this recipe, you will need everything mentioned in the Technical requirements section at the start of the chapter.
How to do it…
Let’s create a materialized view using the CREATE MATERIALIZED...