CouchDB视图和设计文档 [英] CouchDB Views and Design Documents

查看:84
本文介绍了CouchDB视图和设计文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于CouchDB,您可以创建多个视图和/或多个设计文档。

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?

推荐答案

内部,每个设计文档中的视图都在视图组中一起管理。每个视图组在访问时都会生成一个单独的视图服务器-即,如果有8个视图组,则将有8个JavaScript进程。这当然具有设计和性能方面的含义。从CouchDB 文档

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.

您也可以利用视图组-视图服务器关系来发挥自己的优势。例如,如果您的CPU具有8个核心,则可能会有8个视图组,每个核心1个视图组,以改善并行性。

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.

这篇关于CouchDB视图和设计文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆