Materialized view
   HOME

TheInfoList



OR:

In
computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, a materialized view is a
database In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases ...
object that contains the results of a query. For example, it may be a local copy of data located remotely, or may be a subset of the rows and/or columns of a table or
join Join may refer to: * Join (law), to include additional counts or additional defendants on an indictment *In mathematics: ** Join (mathematics), a least upper bound of sets orders in lattice theory ** Join (topology), an operation combining two topo ...
result, or may be a summary using an aggregate function. The process of setting up a materialized view is sometimes called materialization.Compare: This is a form of caching the results of a query, similar to
memoization In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. Memoization ...
of the value of a function in functional languages, and it is sometimes described as a form of precomputation. As with other forms of precomputation, database users typically use materialized views for performance reasons, i.e. as a form of optimization. Materialized views which store data based on remote tables were also known as snapshots (deprecated Oracle terminology). In any
database management system In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases ...
following the
relational model The relational model (RM) is an approach to managing data using a structure and language consistent with first-order predicate logic, first described in 1969 by English computer scientist Edgar F. Codd, where all data is represented in terms of t ...
, a view is a virtual table representing the result of a
database In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases ...
query. Whenever a query or an update addresses an ordinary view's virtual table, the DBMS converts these into queries or updates against the underlying base tables. A materialized view takes a different approach: the query result is cached as a concrete ("materialized") table (rather than a view as such) that may be updated from the original base tables from time to time. This enables much more efficient access, at the cost of extra storage and of some data being potentially out-of-date. Materialized views find use especially in
data warehousing In computing, a data warehouse (DW or DWH), also known as an enterprise data warehouse (EDW), is a system used for reporting and data analysis and is considered a core component of business intelligence. DWs are central repositories of integr ...
scenarios, where frequent queries of the actual base tables can be expensive. In a materialized view, indexes can be built on any column. In contrast, in a normal view, it's typically only possible to exploit indexes on columns that come directly from (or have a mapping to) indexed columns in the base tables; often this functionality is not offered at all.


Implementations


Oracle

Materialized views were implemented first by the
Oracle Database Oracle Database (commonly referred to as Oracle DBMS, Oracle Autonomous Database, or simply as Oracle) is a multi-model database management system produced and marketed by Oracle Corporation. It is a database commonly used for running online ...
: the Query rewrite feature was added from version 8i. Example syntax to create a materialized view in Oracle: CREATE MATERIALIZED VIEW MV_MY_VIEW REFRESH FAST START WITH SYSDATE NEXT SYSDATE + 1 AS SELECT * FROM ;


PostgreSQL

In
PostgreSQL PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the ...
, version 9.3 and newer natively support materialized views. In version 9.3, a materialized view is not auto-refreshed, and is populated only at time of creation (unless WITH NO DATA is used). It may be refreshed later manually using REFRESH MATERIALIZED VIEW. In version 9.4, the refresh may be concurrent with selects on the materialized view if CONCURRENTLY is used. Example syntax to create a materialized view in PostgreSQL: CREATE MATERIALIZED VIEW MV_MY_VIEW WITH_(storage_parameter_[=_value[,_..._.html" ;"title="_value.html" ;"title="WITH (storage_parameter [= value">WITH (storage_parameter [= value[, ... ">_value.html" ;"title="WITH (storage_parameter [= value">WITH (storage_parameter [= value[, ... ] [ TABLESPACE tablespace_name ] AS SELECT * FROM ;


SQL Server

Microsoft SQL Server differs from other RDBMS by the way of implementing materialized view via a concept known as "Indexed Views". The main difference is that such views do not require a refresh because they are in fact always synchronized to the original data of the tables that compound the view. To achieve this, it is necessary that the lines of origin and destination are "deterministic" in their mapping which limits the types of possible queries to do this. This mechanism has been realised since the 2000 version of SQL Server. Example syntax to create a materialized view in SQL Server: CREATE VIEW MV_MY_VIEW WITH SCHEMABINDING AS SELECT COL1, SUM(COL2) AS TOTAL FROM GROUP BY COL1; GO CREATE UNIQUE CLUSTERED INDEX XV ON MV_MY_VIEW (COL1);


Stream processing frameworks

Apache Kafka Apache Kafka is a distributed event store and stream-processing platform. It is an open-source system developed by the Apache Software Foundation written in Java and Scala. The project aims to provide a unified, high-throughput, low-latency plat ...
(since v0.10.2),
Apache Spark Apache Spark is an open-source unified analytics engine for large-scale data processing. Spark provides an interface for programming clusters with implicit data parallelism and fault tolerance. Originally developed at the University of Califor ...
(since v2.0), Apache Flink, Materialize, and RisingWave all support materialized views on streams of data.


Others

Materialized views are also supported in
Sybase Sybase, Inc. was an enterprise software and services company. The company produced software to manage and analyze information in relational databases, with facilities located in California and Massachusetts. Sybase was acquired by SAP in 2010; ...
SQL Anywhere. In
IBM Db2 Db2 is a family of data management products, including database servers, developed by IBM. It initially supported the relational model, but was extended to support object–relational features and non-relational structures like JSON a ...
, they are called "materialized query tables". ClickHouse supports materialized views that automatically refresh on merges.
MySQL MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database ...
doesn't support materialized views natively, but workarounds can be implemented by using triggers or stored procedures or by using the open-source application Flexviews. Materialized views can be implemented in
Amazon DynamoDB Amazon DynamoDB is a fully managed proprietary NoSQL database service that supports key–value and document data structures and is offered by Amazon.com as part of the Amazon Web Services portfolio. DynamoDB exposes a similar data model to and ...
using data modification events captured by DynamoDB Streams. Google announced in 8 April 2020 the availability of materialized views for BigQueryGoogle BigQuery Materialized Views documentation
Google.com Retrieved on 2020-05-20. as a beta release.


References


External links



* ttp://download.oracle.com/docs/cd/B10501_01/server.920/a96568/rarmviea.htm#94135 Oracle9i Replication Management API Reference Release 2 (9.2)br>Materialized Views in Oracle 11.2Creating Materialized Views In MySQL
{{Databases Relational model Data modeling Database management systems Databases Articles with example SQL code