Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 60995 invoked from network); 28 Jun 2008 06:03:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Jun 2008 06:03:36 -0000 Received: (qmail 73852 invoked by uid 500); 28 Jun 2008 06:03:37 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 73821 invoked by uid 500); 28 Jun 2008 06:03:36 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 73810 invoked by uid 99); 28 Jun 2008 06:03:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2008 23:03:36 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dking@ketralnis.com designates 68.183.67.83 as permitted sender) Received: from [68.183.67.83] (HELO ketralnis.com) (68.183.67.83) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 Jun 2008 06:02:46 +0000 Received: from [10.0.0.234] ([10.0.0.234]) (authenticated bits=0) by ketralnis.com (8.14.2/8.14.2) with ESMTP id m5S634KU019261 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 27 Jun 2008 23:03:05 -0700 (PDT) (envelope-from dking@ketralnis.com) Message-Id: <3F12B537-F1E1-45A5-857E-53E8CD5EC73E@ketralnis.com> From: David King To: couchdb-user@incubator.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v924) Subject: General-understanding questions about views Date: Fri, 27 Jun 2008 23:03:04 -0700 X-Mailer: Apple Mail (2.924) X-Virus-Checked: Checked by ClamAV on apache.org I'm trying to gain a fundamental understanding of views and indexed data. If this is documented in a FAQ, please direct me there instead :) In trying to map my understanding from SQL, it appears that the answer to quickly querying data is by pre-calculating query result-sets and storing them in tables, called views. A view is table populated by a function that runs against every object that is written or modified in the database. 1. How would you implement a query against a value that changes after the view is populated, like the current time? That is, if I wanted things younger than a week, a permanent view like this: function(doc) { if(doc.date > now() - timeinterval('1 week')) { emit(null,doc); } } (date-syntax liberally made up) the results of that query, if populated when the data is changed, would quickly be invalid, because now() has changed. Is this accurate? How would you performantly run a query like this? 2. Same question for a permanent view containing the youngest 10 items (this one might be easier)? 3. The wiki doesn't mention parameterised views. So if I have a document with an 'author' field, and I want a view such that I can see everything that a given author wrote, do I need a view per author? Given thousands of authors, what is the performance cost for running a document through a few thousand author-functions? 4. I know that the distribution bits are still being fleshed out, but is it the intention that eventually views can be stored or calculated on a separate server from the data (since they are implemented as tables)?