Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 55586 invoked from network); 14 Jul 2008 23:20:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Jul 2008 23:20:05 -0000 Received: (qmail 6812 invoked by uid 500); 14 Jul 2008 23:20:04 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 6777 invoked by uid 500); 14 Jul 2008 23:20:04 -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 6766 invoked by uid 99); 14 Jul 2008 23:20:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 16:20:04 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 209.85.146.177 as permitted sender) Received: from [209.85.146.177] (HELO wa-out-1112.google.com) (209.85.146.177) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2008 23:19:09 +0000 Received: by wa-out-1112.google.com with SMTP id m16so3150625waf.6 for ; Mon, 14 Jul 2008 16:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=8e87oxUo35AAcqJSwAvXhSNuBChgBbWDW3vMB4SoVJ8=; b=M5EyfHopVaX1pdaS7WahmHfVwO1RH1DiPaTZ6sCZsX7hXwPgWhP+wMVqzmaLGAg66I rwWabFYAEpeLxW+tnmgmHHx7nYSGRRZA9RYBEtkQP3gGXKzJw4UnIO6MNyFqFRShuwno Mu7UNM0rkBWuFpSSL8s5VERpkyWLT6I23BQew= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=d1OPPrja00xclJZTjVHJWv4wlPKbQWhmHzDTJ4xFZr7NdcR8JaOLP2m0cTIKHwvNQn Dp6oK1hwnMLsk/MQB5zHCacnPnPysA+bqYSbCB/67IBmdBGg0O6kYBiN4pqZjA9kb4Hl DSVJYugMWa8G+bkLMw6OszBl5C6bHGG/rYUgQ= Received: by 10.114.185.8 with SMTP id i8mr18373424waf.28.1216077572755; Mon, 14 Jul 2008 16:19:32 -0700 (PDT) Received: by 10.114.78.7 with HTTP; Mon, 14 Jul 2008 16:19:28 -0700 (PDT) Message-ID: Date: Mon, 14 Jul 2008 16:19:28 -0700 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: when to use another document and when not to? In-Reply-To: <64a10fff0807141604i6f4c5778meba60a1f634f518b@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6b6419750807141546q63431cfek69184295a1cb25b0@mail.gmail.com> <64a10fff0807141604i6f4c5778meba60a1f634f518b@mail.gmail.com> X-Google-Sender-Auth: 950013a36bcc581a X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Jul 14, 2008 at 4:04 PM, Dean Landolt wrote: > I've been wrestling with this myself, and the only rule of thumb that makes > any sense to me is just to spin off a new object if the new type of data > tends to grow rather than change. In the example you put forth, that seems > like the kind of data structure that is subject to change so it seems like a > better candidate for nesting inside the parent doc. If it were something > more akin to logging information, it probably belongs in its own doc just > due to versioning overhead that would be created by creating a whole new doc > for every new write... I'd agree with your recommendation - having the information together in 1 doc will make it easier to generate the views you'll want to use, and updating the user's doc is a relatively low-contention activity. I split data into multiple docs in cases where I don't want to have to load the original doc to make changes and then re-save it. In your case, you won't be adding to a user's friends unless the user is around (as in visiting your website) so you've probably already loaded the user's doc up. Also, a user probably isn't making concurrent write-requests to different replicas of your data, so saving changes to user docs shouldn't result in conflicts very frequently. In the case of logging or metrics application, you probably want to split docs so that you never end up changing them, because doing the GET / PUT loop for every additional chunk of information will add a lot of overhead. Also, building views from the small atomic data chunks probably makes the most sense. -- Chris Anderson http://jchris.mfdz.com