Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 38737 invoked from network); 19 Dec 2010 10:27:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Dec 2010 10:27:38 -0000 Received: (qmail 46951 invoked by uid 500); 19 Dec 2010 10:27:37 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 46676 invoked by uid 500); 19 Dec 2010 10:27:36 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 46668 invoked by uid 99); 19 Dec 2010 10:27:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Dec 2010 10:27:36 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bosak.tomas@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Dec 2010 10:27:29 +0000 Received: by vws13 with SMTP id 13so929342vws.11 for ; Sun, 19 Dec 2010 02:27:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=hTUSQ8FViq3OS3HN2aJ/B/Ao93VCYHxl8hl6ex5VDl8=; b=XazJ7pVZ9V60VFXHWjGGk6gWqrteE2hbQ5oGNjoWI1R/AVxrGy2O8Z/mP52ZTaajp1 FRVO/kjIhLTeahvK8/9zSJnWGrfQjMgMknp7g9WbldyOIUK0rD8xv5unmYblbLYAtcOU AROSlo7yGnLFj5IoLX9Ub8HYcjeojwR8Tt73E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=KMlOZ5Tx3EZa16dQN2W76TVyQbqmvKiCvDYJBCV0/C9iGfqeBHd4sYf75aGpe0Ez63 btaMP1CJKOS5LRdj7fAM7swW7zOB60Raskt0ZXJKthT8WY8kDVDUKB5IztHwFXKA11t6 MCxkiEpnAjewf1YmMXGtPYVFisLwq7r9Uw4yc= MIME-Version: 1.0 Received: by 10.220.202.196 with SMTP id ff4mr904858vcb.6.1292754427616; Sun, 19 Dec 2010 02:27:07 -0800 (PST) Received: by 10.220.179.193 with HTTP; Sun, 19 Dec 2010 02:27:07 -0800 (PST) Date: Sun, 19 Dec 2010 11:27:07 +0100 Message-ID: Subject: CouchDB querying pattern From: Tomi To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hi folks! Is it a good idea to query couchdb like this: - stored documents have format like this: { "_id": ..., "_rev": ..., "Title": "Test title", "Accounts": ["joe", "johny"], "Labels": ["work", "school", "programming"], "Status": 0, "Type": "ticket" } - map function will generate rows where keys consists of document field name and it's value (multiple times when it's an array): function(doc) { if(doc.Type && (doc.Type == "ticket")) { emit(["_id", doc._id], null); emit(["title", doc.Title], null); for(var index in doc.Accounts) { emit(["accounts", doc.Accounts[index]], null); } for(var index2 in doc.Labels) { emit(["labels", doc.Labels[index2]], null); } emit(["status", doc.Status], null); } } - list function[1] will merge the map function result based on data sent in POST like this: curl -X POST -d '{"keys":[["accounts","joe"],["labels","school"],["status",2]]}' -H "Content-Type: application/json" http://127.0.0.1:5984/testdb/_design/docs/_list/listTest/adhoc?include_docs=true Result contains only "ticket" type documents which have "joe" in Accounts field, "school" in Labels field and number 2 in Status field. Is it a good idea to use this "pattern" for "ad-hoc querying" in couchdb? I can imagine that database with millions of documents (or with thousands of documents where each document have lots of fields or big arrays) could have serious performance issues due to map and list function from this scenario. Thanks for your help and time. [1] http://www.vertigrated.com/blog/2010/04/generic-ad-hoc-queries-in-couchdb/