CouchDB Views - Results List Performance Feature?

How many of you will find out the answer from couchdb view as follows

{"rows":[ {"key":"1","value":{"Col1":"Some Value"}}, {"key":"2","value":{"Col1":"Another Value"}}, ]} 

Well, I would like to contrast this with

 [{"key":"1","value":{"Col1":"Some Value"}}, {"key":"2","value":{"Col1":"Another Value"}}] 

I am considering using a “list function” to match an answer, but I wanted to know the potential overhead performance to do something like this? Is it worth it ... or should I consider changing my entire code to handle a different answer?

Thanks Damo

+3
source share
2 answers

The list function is launched in a separate process ( couchjs ), which connects to couchdb through standard input / output. Data is transferred to / from JSON to communicate with this channel. In other words, all your lines will be serialized and sent to couchjs ; and couchjs will send the results back.

Therefore, the list function will add (at least) an O (n) delay to get your results. For small (I say less than 10,000 documents, but it depends on your needs) viewing results, it's worth it. For a very large number of lines, you can take advantage of updating your clients.

+5
source

I use JSON_XS to format the result, then curl, awk and other unix utilities to reformat the result. In this case, the pretty-printed version of JSON does not help:

curl -s -S --compressed -X GET 'your_view_url' | sed -e '/^{"rows"://' -e '/^]}/]/'

0
source

Source: https://habr.com/ru/post/1480803/


All Articles