Due to the nature of the Couchbase cluster and because of the size of the datasets that can be stored across a cluster, the impact of view development needs to be controlled. Creating a view implies the creation of the index which could slow down the performance of your server while the index is being generated. However, views also need to be built and developed using the actively stored information.
To support both the creation and testing of views, and the deployment of views in production, Couchbase Server supports two different view types, “Development” views and “Production” views. The two view types work identically, but have different purposes and restrictions placed upon their operation.
Development Views
Development views are designed to be used while you are still selecting and designing your view definitions. While a view is in development mode, views operate with the following attributes
By default the development view works on only a subset of the stored information. You can, however, force the generation of a development view information on the full dataset.
Uses live data from the selected Couchbase bucket, enabling you to develop and refine your view in real-time on your production data.
Development views are not automatically rebuilt, and during a rebalance operation, development views are not updated, even when when consistent views are enabled, as this relies on the automated update mechanism. Updating development views in this way would waste system resources.
Development views are full editable and modifiable during their lifetime. You can change and update the view definition for a development view at any time.
During development of the view you can view and edit stored document to help develop the view definition.
Development views are accessed from client libraries through a different URL than production views, making it easy to determine the view type and information during development of your application.
Within the Web Console the execution of a view by default occurs only over a subset of the full set of documents stored in the bucket. You can elect to run the View over the full set using the Web Console.
Because of the selection process, the reduced set of documents may not be fully representative of all the documents in the bucket. You should always check the view execution over the full set.
Production Views
Production views are optimized for production use. A production view has the following attributes:
Production views always operate on the full dataset for their respective bucket.
Production views cannot be modified through the UI. You can only access the information exposed through a production view. To make changes to a production view, it must be copied to a development view, edited, and re-published.
Views can be updated by the REST API, but updating a production design document immediately invalidates all of the views defined within it.
Production views are accessed through a different URL to development views.
The support for the two different view types means that there is a typical work flow for view development, as shown in the figure below:
The above diagram features the following steps:
Create a development view and view the sample view output.
Refine and update your view definition to suit your needs, repeating the process until your view is complete.
During this phase you can access your view from your client library and application to ensure it suits your needs.
Once the view definition is complete, apply your view to your entire Cluster dataset.
Push your development view into production. This moves the view from development into production, and renames the index (so that the index does not need to be rebuilt).
Start using your production view.
Individual views are created as part of a design document. Each design document can have multiple views, and each Couchbase bucket can have multiple design documents. You can therefore have both development and production views within the same bucket while you development different indexes on your data.
For information on publishing a view from development to production state, see Section 6.5.2, “Publishing Views”.