First of all thank you for CouchDB 2.0!

I would like to add some thoughts if I may. I have been working for a long time 
with CouchDB, and I think 2.0 is a great step ahead, but I like to address some 
obstacles I have found during the development of a social network platform with 
versioning support.

Bitwise Operators
————————
String comparison is slow compared to integers. In the social network app I 
have created, a post can assume different states at the same time. Currently, 
on CouchDB 1.6 in some views I have used an integer to store the state, and 
bitwise operators to compare it (in the map functions). As far as I know 
unfortunately Mango doesn’t support them.
Mango has been influenced by MongoDB, and MongoDB has bitwise operators 
(https://docs.mongodb.com/manual/reference/operator/query-bitwise/ 
<https://docs.mongodb.com/manual/reference/operator/query-bitwise/>). It should 
be easy to implement.

Joins
———
Well, this would be awesome. I really dunno how people may have used CouchDB in 
the past without the ability to make joins. Some time ago I have proposed to 
add an option to the Query Options, to return a row even for the null rows. 
This enable the programmer to make join over the results. I tried to modify 
CouchDB myself, but it wasn’t so easy like I thought. Since I have tried to 
patch CouchDB myself, I can say that it’s not just ErLang, is the code itself 
the problem. It’s hard to debug and the documentation is quite absent. That’s 
why I have decided to implement the feature in the PHP client library I made. 
3.0 is a long way, this could be done pretty fast by someone who knows about 
CouchDB internals. I guess Elixir will not attract many people if they found 
hard to hack the source code, unless you rewrite it in Elixir.
Please see this: https://issues.apache.org/jira/browse/COUCHDB-1868 
<https://issues.apache.org/jira/browse/COUCHDB-1868>

Lazy Loading
——————
I don’t know if CouchDB 2.0 comes with such a feature, but I would like to have 
a mechanism to get just some document’s fields. Sometime I just need the title 
or whatever, but I have to get the entire document. I would like to request 
just a set of fields when I retrieve a document from the database. Using the 
Lazy Loading pattern I could require other fields when I need them. This is 
especially useful when applied to object oriented mapping.
Please don’t tell me to use a show function.

Order by value
———————
We really need a way to order against the result of a reduce function, by 
value. For example, there is no way to retrieve the top comments of a post 
(comments ordered by number of votes). This is something you can easily do with 
a trigger in almost any RDMS (or with a slow query). We need a way to do things 
like this, maybe clustered triggers?

To overcome many of these problems I have used Redis to caches indexes. I run 
most of the queries against these indexes. And I use CouchDB as a store. I have 
implemented a system to regenerate the entire Redis cache in case of disaster 
recovery. Honestly, there are too many limitations with CouchDB, and sometimes 
I regret my choice. Mango and the clustering support are awesome. Everything is 
important, but the most important thing to do is to overcome the design 
limitations. I know the perfect database doesn’t exist, but a developer needs 
his Swiss Army knife. It’s a real pain in the ass when you want do something 
and you can’t because you don’t have the tools. A DBMS might not be the best 
solution to serve a particular purpose, but it provides every tool you need.

For the rest I’m all in line with Jan.

By the way, if you don’t like using cURL from the command line, you can use the 
Elephant on Couch CLI (https://github.com/dedalozzo/eoc-cli 
<https://github.com/dedalozzo/eoc-cli>). I will add Mango support as soon as I 
can.

-Filippo


Reply via email to