Professional Documents
Culture Documents
Materialized View
Materialized View
Materialized View
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 result, or may be a summary using an aggregate
function.
This is a form of caching the results of a query, similar to memorization of the value of a
function in functional languages, and it is sometimes described as a form of pre-
computation.
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 are also known as snapshots.
Materialized View
Difference Between View and Materialized View
Definition of View
View can be created from one or more than one base tables or views.
If you update any content in View, it is reflected in the original table, and if any
changes had been done to the original base table, it would reflect in its View.
For example, a view is created from the join of two or more tables.
In that case, you have to pay time to resolve Joins each time a View is used.
But it has some advantages like it do not require storage
space.
C re a t e V ie w V A s < Q u e r y E x p r e s s i o n >
Note: all View are not updateable.
C r e a t e M a t e ri a l i z e d Vi e w V
Bu i ld [ c l a u s e ] R e f r e sh [ t y p e ]
ON [trigger ]
A s < q u e r y e x p r e s si o n >
Where Build clause decides, when to populate the Materialized
View.
BASIS FOR
VIEW MATERIALIZED VIEW
COMPARISON
Eager
The materialized view is updated when the base tables are updated.
This approach is good when we have more frequent reads than writes
Lazy:
We can read the data, computing the view, and saving it back to
the database (MapReduce).
1. Sharding
2. Replication
Sharding: Sharding distributes different data across multiple servers, so each server
acts as the single source for a subset of data.
Replication: Replication copies data across multiple servers, so each bit of data can be
found in multiple places.
Replication comes in two forms:
Like Riak database shards the data and also replicates it based on
the replication factor.
What is Database Sharding?
A database can be
For instance, user may choose userID as the shard key in a social
media app.
Queries