Details
Description
Our documentation for views says only
Views are computed on demand during read operations, and MongoDB executes read operations on views as part of the underlying aggregation pipeline.
(in a section titled View Creation).
While that is all correct, more detail is needed. I suggest something like:
What happens when you run a query against a view is:
- the query filter, projection, sort, skip, limit etc parts of the find command are converted to their equivalent aggregation stages.
- those stages are added to the end of the aggregation pipeline in the view definition.
- Aggregation Pipeline Optimization then reorders and/or coalesces stages where doing so will give a performance benefit while not changing the results.
(and it would probably be appropriate under the heading for Behaviour on the same page.