From the course: Advanced MongoDB: Efficient and Secure Data Management

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

On-demand materialized views

On-demand materialized views

- [Instructor] An on demand materialized view is a collection created from the output of an aggregation pipeline. Initially, you can use the $out or the $merge aggregation stages to create the collection. Once created the materialized view will not be updated until you run another aggregation pipeline with a $merge stage. As such the contents of the materialized view may be outdated. This is a bit like a snapshot. So you get a snapshot of the results at the time when the aggregation pipeline was last run. To update the results of the materialized view, you can run the same aggregation pipeline with the $merge operator to update the collection with the latest results. Let's look at collections, views, and on demand materialized views side by side. The biggest difference is how these collection types look on disk. Regular collections are persisted to disk. When you query a regular collection, the data is retrieved…

Contents