Infinite resets hanging views (see thread)
Question: a user is trying to run a temporary view on a big-ish db (> 1000 docs), and the view seemed to hang forever, and they were not sure if there was something wrong with their view or settings. The view looked like this:
# map function
Answers / approaches:
- Think of `map` as a way to create secondary indexes.
- An index on the whole document doesn’t make much sense.
- Moreover, at query time, if you want to get data that are in the same document, need map/reduce isn’t needed at all. Just create a `show` function.
- I would go further and say: Never emit the full doc in a map function.
You can get the full doc by using the include_docs flag when querying the
view. If you need a key that only refers to a single doc, use the _id of
- Don’t write your own reduce functions, use couch’s built in, Erlang functions (See http://wiki.apache.org/couchdb/Built-In_Reduce_Functions). You will save yourself a lot of headaches and you will not match the performance of these functions. In your case, _count is probably what you want, though you probably don’t even need a reduce function with such an index (as Aurelien essentially pointed out). Handle the case where doc.tweets doesn’t exist in your map function:
emit(doc._id, doc.tweets || );
Allow user-defined views (see thread)
Question: a user was thinking about a platform based on CouchDB, where each set of users would get their own CouchDB Database, to store and query data. They want to allow them to define their own custom queries to query the data and want to create a form which allows to build a query and translates it to a JS view, and, on top of that, defining custom views directly in JS – basically their custom map/reduce functions. The users would also be able to import different sets of data. Still, they were not sure about possible DoS attacks with endless loops inside the function, or attacks by emiting too much data.
- os_process_timeout applies to view servers (default is 5 seconds) so you can configure the timeout for view queries, not sure about CPU/HDD Space (although inspecting _stats might shed some light).
- If viable for the application, it may also be possible to initially have a process where new queries written are vetted by a human before they are run. The advantage of this is two-fold, namely:
- i) you’ll be able to move on a prove your concept quickly
- ii) while doing this, you may learn enough (and things may change enough) for you to automate the vetting process.
- The worst case will be always RCE since you’re going allow everyone
- The idea may work for Mango – Cloudant views query DSL – since it’s very limited by allowed operations, but then you’ll face another problem: disk space will run out very quickly since a single index file may be much more bigger then database itself.
- For now the most simple and secure way to allow custom users view is to let users replicate your database to their CouchDB instance where they can do anything whatever they need.
- Another approach: use CouchDB for whatever you need on the server side, and when a user needs to run a custom query, run that query on a client-side copy of the data in PouchDB. This wouldn’t work with very large data sets, but would work on smaller data sets.
- Alternatively, don’t allow the user to write the view. Build some Ui that helps creating the view function, specify some things that can be run on the data and construct the view with that. This is essentially a query builder for CouchDB.
Releases in the CouchDB Universe
- couchbeam 1.1.3 – a maintenance release
- pouchdb-replicator 2.1.0 – PouchDB plug-in that simulates CouchDB’s replicator database daemon
- express-pouchdb 0.7.3 – Express submodule with a CouchDB style REST interface to PouchDB
- loopback-connector-couch 0.1.0 – CouchDB adapter for Loopback.io
- couch-cli 0.0.12 – a little CLI tool for CouchDB webapps
- follow 0.11.4 – extremely robust, fault-tolerant CouchDB changes follower
- goappes – four new Hoodie Plugins
Opinions and other News in the CouchDB Universe
- Let’s learn Erlang and fix a bug on a CouchDB Cluster #1
- Why you need NoSQL for the Internet of Things
Use Cases, Questions and Answers
- Stack Overflow: Resolve Pouch Couch DB
- Stack Overflow: The pricing programs of hosted CouchDB providers do not make sense
- Stack Overflow: Can’t access CouchDB instance: returns 401 Unauthorized
No public answer yet:
- Stack Overflow: Display CouchDB Data in Bootstrap Table
- Stack Overflow: JSON-diff capability on the replication process of couchdb
- Stack Overflow: Angular and CouchDB Authentication
- Stack Overflow: Updating CouchDB from Ruby Script
- Stack Overflow: Get attachments list in CouchDB using Mustaches.js
- Stack Overflow: How to update indices rows automatically when CouchDB is updated using elasticsearch in Node.js
For more new questions and answers about CouchDB, see these search results.
If you want to get into working on CouchDB:
- We have an infinite number of open contributor positions on CouchDB. Submit a pull request and join the project!
- Can you help with Web Design, Development or UX for our Admin Console? No Erlang skills required! – Get in touch with us.
- Do you want to help moving the CouchDB docs translation forward? We’d love to have you in our L10n team! See our current status and languages we’d like to provide CouchDB docs in on this page. If you’d like to help, don’t hesitate to contact the L10n mailing list on email@example.com or ping Andy Wenk (awenkhh on IRC).
We’d be happy to have you on board!
- December 09, Hamburg, Germany: CouchDB Meetup Hamburg
- December 11, Berlin, Germany: CouchDB Hack Night Berlin
- December 12, Vienna, Austria: ViennaDB Xmas Gathering
- February 7, 2015: CouchDB Day 2015, Hamburg, Germany; ticket sale is now open
Job opportunities for people with CouchDB skills
Time to relax!
- “If you’re a programmer, please don’t denigrate what a beginner is currently learning … unless you’re willing to personally invest the enormous amount of time to ensure that they learn what you want them to learn.” –
Programmers: please don’t ever say this to Beginners …
- “Focus on a single next action. Ruthlessly ignore the future. Nothing else matters right now.” – Productivity for the Depressed
- “Will one thing ever be enough? Or are we doomed with a constant fear of becoming irrelevant? Are we able to focus on a single thing for 13 years, or will we become dated in our own field?” – If you could dedicate yourself to mastering one thing for 13 years, what would it be?
… and also in the news
- ES6 Modules: The End of Civilization as we know it?
- If Tech Companies wanted to end online harassment, they could do it tomorrow
- On Corporate Ownership of Open Source
- The saddest thing I know about the Integers
- “changing from mongodb to couchdb on my Raspberry Pi for a project that will have a db larger than 2GB, more than 1 million documents” (@ugosan, on Twitter)
- “Late night conference call revealed that the client is keen to build the next project on Node.js and CouchDB.
#SuperExcited” (@JeffBallweg, on Twitter)