Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 13876 invoked from network); 7 Jan 2010 09:51:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Jan 2010 09:51:53 -0000 Received: (qmail 32888 invoked by uid 500); 7 Jan 2010 09:51:53 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 32795 invoked by uid 500); 7 Jan 2010 09:51:53 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 32781 invoked by uid 500); 7 Jan 2010 09:51:53 -0000 Delivered-To: apmail-incubator-couchdb-commits@incubator.apache.org Received: (qmail 32778 invoked by uid 99); 7 Jan 2010 09:51:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jan 2010 09:51:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jan 2010 09:51:52 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 06CD61781C; Thu, 7 Jan 2010 09:51:31 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Thu, 07 Jan 2010 09:51:31 -0000 Message-ID: <20100107095131.13434.44867@eos.apache.org> Subject: =?utf-8?q?=5BCouchdb_Wiki=5D_Update_of_=22Introduction=5Fto=5FCouchDB=5Fv?= =?utf-8?q?iews=22_by_BrianCandler?= Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for c= hange notification. The "Introduction_to_CouchDB_views" page has been changed by BrianCandler. The comment on this change is: Note about equal keys and docids. http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views?action=3Ddiff&= rev1=3D25&rev2=3D26 -------------------------------------------------- = For queries which are not meant to actually condense the amount of inform= ation you often can live without a reduce function. A common strategy is to= get the data you are interested to select by in into the ''key'' part and = then use ''startkey'' and ''endkey'' on the result. = + =3D=3D Equal keys =3D=3D + = + CouchDB actually stores the [key,docid] pair as the key in the btree. Thi= s means that: + * you always know which document the key and value came from (it's expos= ed as the 'id' field in the view result) + * view rows with equal keys sort by increasing docid. + = + If you assign your docids in a time-based way then you can get documents = with equal keys in a natural oldest-to-newest order. Couchdb has a feature = to do this, which you can enable in local.ini: + = + {{{ + [uuids] + algorithm =3D utc_random + }}} + = =3D=3D Lookup Views =3D=3D = - The second parameter of the ''emit()'' function can be ''NULL''. CouchDB = then only stores the key in the view. If you use the document's ID here, yo= u can use the view as a compact lookup mechanism and fetch the document's d= etails, if needed, in subsequent requests. + The second parameter of the ''emit()'' function can be ''null''. CouchDB = then only stores the [key,docid] in the view. You can use the view as a com= pact lookup mechanism and fetch the document's details, if needed, in subse= quent requests or by adding parameter ''include_docs=3Dtrue'' = =3D=3D Complex Keys =3D=3D =20