For CouchDB you can create multiple views and/or multiple design documents.
Is it better to group views in the same design document or keep each view to its own design document?
Internally, views within each design document are managed together in a "view group". Each view group spawns a separate view server when accessed - i.e. if there are 8 view groups, you will have 8 JavaScript processes. This certainly has design and performance implications. From the CouchDB documentation,
View index rebuilds occur when one view from the same the view group (i.e. all the views defined within a single a design document) has been determined as needing a rebuild. For example, if you have a design document with different views, and you update the database, all three view indexes within the design document will be updated.
So, from a design/deployment perspective, you need to be aware that changing a single view will rebuild all of the other views within the design document. You can use this trick to build them in the background but it is still going to build all of the views in the group so is potentially expensive.
You can also use the view group-view server relationship to your advantage. For example, if you have a CPU with 8 cores you might have 8 view groups, 1 for each core, to improve parallelism.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With