Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 791BF790F for ; Sun, 24 Jul 2011 22:42:03 +0000 (UTC) Received: (qmail 65592 invoked by uid 500); 24 Jul 2011 22:42:01 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65291 invoked by uid 500); 24 Jul 2011 22:42:01 -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 65283 invoked by uid 99); 24 Jul 2011 22:42:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jul 2011 22:42:00 +0000 X-ASF-Spam-Status: No, hits=0.9 required=5.0 tests=FREEMAIL_FROM,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dbfclark@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jul 2011 22:41:51 +0000 Received: by iyh42 with SMTP id 42so6329654iyh.11 for ; Sun, 24 Jul 2011 15:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:references:from:content-type:x-mailer:in-reply-to :message-id:date:to:content-transfer-encoding:mime-version; bh=K0lR1NoKY2zgxTU0TEYHVMhLR99yLZcB1H9MIoSS4J4=; b=LR0ZfaeD+j5yjmJRH6loNa3ZYd3NW3+KBP+egZSL4SZ+PAQFh4uii3LRlkDpDxNbdT bOOgPGAYbAkC8x/FQ9um1GU3e3kag5Ok95N9TUSsvU+Pdxs5dwrLeLfqZ5mGQ7XXM0dl QX1WdKPvEdvZyE9LcXktUcoy9QYBqoVuC9CL8= Received: by 10.231.84.67 with SMTP id i3mr3871374ibl.187.1311547290341; Sun, 24 Jul 2011 15:41:30 -0700 (PDT) Received: from [10.120.84.9] (mobile-166-137-137-144.mycingular.net [166.137.137.144]) by mx.google.com with ESMTPS id q13sm2797763ibi.9.2011.07.24.15.41.28 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 24 Jul 2011 15:41:29 -0700 (PDT) Subject: Re: 1 large view vs 2 smaller views References: From: Dennis Clark Content-Type: text/plain; charset=us-ascii X-Mailer: iPhone Mail (8J2) In-Reply-To: Message-Id: <1B706292-E785-4F53-927E-2B0DC7E8434D@gmail.com> Date: Sun, 24 Jul 2011 18:41:21 -0400 To: "user@couchdb.apache.org" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (iPhone Mail 8J2) X-Virus-Checked: Checked by ClamAV on apache.org You won't be able to use just that view to get the sorbability you want, the= n -- lexicographic ordering means that that your example will sequence your k= eys by doc.depth first, so you couldn't query and get all docs with the same= date or date range. Perhaps best to step back a second and explain a little more about what you'= re trying to do? We can probably help, but only with a hair more input. On Jul 24, 2011, at 6:24 PM, Ganzha Alexey wrote: > Thanks for your answer. >=20 > Actually it is very important to sort by the other fields: dep, price. eve= n > _id i need to separate docs with the same price. > So, the only way i see - this additional "week" (''THIS_IS_FOR_ALL'', > 'THIS_IS_FOR_LAST_WEEK_ > ONLY') element in the key, at the first place. And i have to match this > element exactly for all docs, or for week docs. >=20 >=20 > On Mon, Jul 25, 2011 at 12:54 AM, Dennis Clark wrote:= >=20 >> How important is it to you to have the view sorted by doc.dep? If the >> answer >> is "not at all," the idiomatically CouchDB way to do this is: >>=20 >> emit(doc.date,[doc.dep,doc.price,doc._id]); >>=20 >> and then let users query with startkey/endkey if they need only the docs >> from the last week. This way you don't need some "in the last week" field= >> that you have to keep updated. >>=20 >> On Sun, Jul 24, 2011 at 5:46 PM, Ganzha Alexey wrote:= >>=20 >>> Hi. >>> I am trying figuring out whats the better. >>>=20 >>> Say i have a view: >>> ... >>> emit([doc.dep,doc.price,doc.date,doc._id]); >>> ... >>>=20 >>> Some users need all docs. And some of them need only docs for the last >>> week. >>> Just add an attribute 'last_week' in required documents. >>> Then, in the view i will check this attribute and there are 2 cases: >>>=20 >>> Filter docs in 1 view >>>=20 >>> emit(['THIS_IS_FOR_ALL',doc.dep,doc.price,doc.date,doc._id]); >>>=20 >>> if (doc.last_week) >>>=20 >> emit(['THIS_IS_FOR_LAST_WEEK_ONLY',doc.dep,doc.price,doc.date,doc._id]); >>>=20 >>> i will be able to query this view with the additional key member (will >> user >>> need all docs, or only last week docs) >>>=20 >>> Or make 2 separate views. First: >>>=20 >>> emit([doc.dep,doc.price,doc.date,'doc._id]); >>>=20 >>> and Second: >>>=20 >>> if (doc.last_week) >>> emit([doc.dep,doc.price,doc.date,doc._id]) >>>=20 >>> First case will emit more keys, and the keys will be larger by 1 element= . >>> But in second case, there are 2 views. >>>=20 >>> What would you prefer. What is the better for performance? >>> Thanks >>>=20 >>=20