问题描述
我刚刚注意到,在Couchdb的发行说明中提到了2.0,建议将芒果查询用于新的应用程序.还应该提到的是,Mango索引的速度显然比JavaScript查询快2到10倍,这真让我感到惊讶,因此我有很多问题:
I've just noticed that in the release notes of Couchdb 2.0, it is mentionned that Mango queries are recommended for new applications. It is also mentionned that apparently Mango indexes are from 2x to x10 faster than javascript queries which really surprised me, as such I have a number of questions :
- 是否正在逐步淘汰Map/Reduce视图?我期望答案是否定的,因为在我看来Mango并没有涵盖Map/Reduce的所有用例(最简单的示例是Reduce本身),并且这种查询样式的灵活性似乎也受到限制.但由于建议,我更愿意问:
- 我们知道Map/Reduce视图依赖于B树,但是我在文档或邮件列表中找不到关于Mango背后的魔力的任何见解.芒果对我而言本质上是白魔法.但是我可以说,深入了解如何在后台对javascript视图进行索引对于避免陷阱,幼稚的实现以及优化性能非常有帮助.是否有人对芒果的工作方式有任何见解?索引B树也是吗?由于不再有设计文档,何时更新索引?性能提升来自何处? (这些收益对我来说是违反直觉的,因为据我了解,javascript查询的性能来自Map函数的预先计算性质)
我所要追求的基本上是一方面对Mango有一些见解,另一方面概述了Mango和Map/Reduce在2.x时代应该如何生活在一起.
What I'm essentially after is on the one hand some insight regarding Mango and on the other hand, an overview of how Mango and Map/Reduce are supposed to live together in the 2.x era.
推荐答案
核心开发人员的答案:
在Mango下方,正在使用erlang map/reduce.这意味着它是 创建一个B树索引,就像map/reduce一样.使速度更快的是 它使用erlang/native函数创建B树 的JavaScript.我很久以前写了一篇关于内部原理的博客文章 PouchDB查找[1]的内容,这是PouchDB的芒果语法.它可能 帮助您更多地了解内部原理.钥匙 需要了解的是,有一个使用 B树和内存过滤器.理想情况下,内存过滤量越少 加快查询速度.
Underneath Mango is using erlang map/reduce. Which means it is creating a B-tree index just like map/reduce. What makes it faster is that it is using erlang/native functions to create the B-Tree instead of javascript. I wrote a blog post a long time ago about the internals of PouchDB-find [1] which is the mango syntax for PouchDB. It might help you understand a little more how the internals work. The key thing to understand is that there is a Map query part which uses the B-Tree and an in-memory filter. Ideally the less memory filtering you do the faster your query will be.
我想说芒果是一个半成品,但基本 地面工作已经完成.肯定有一些我们可以改进的地方. 我已经看到开发人员开始新项目时使用了很多 因为它可以快速简单地进行基本查询,例如通过电子邮件查找 地址或找到所有名称为"John Rambo"的用户.
I would say that Mango is very much a work in process but the basic ground work is done. There are definitely things we can improve on. I've seen it used quite a bit when developers start a new project because its quick and simple to do basic querying, like find by email address or find all users with the name "John Rambo".
希望有帮助.
[1] http://www.redcometlabs.com/blog/2015/12/1/a-look-under-the-covers-of-pouchdb-find
这篇关于Couchdb Mango性能与Map减少视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!