From user-return-14747-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Feb 02 09:34:03 2011 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 62717 invoked from network); 2 Feb 2011 09:34:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Feb 2011 09:34:03 -0000 Received: (qmail 33571 invoked by uid 500); 2 Feb 2011 09:34:02 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 33269 invoked by uid 500); 2 Feb 2011 09:33:59 -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 33261 invoked by uid 99); 2 Feb 2011 09:33:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 09:33:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.203.160.34] (HELO gatekeeper.vizrt.com) (80.203.160.34) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Feb 2011 09:33:54 +0000 Received: from VizrtFinancePC (10.211.8.136) by MAILBGO.vizrt.internal (192.168.110.25) with Microsoft SMTP Server (TLS) id 8.3.137.0; Wed, 2 Feb 2011 10:33:29 +0100 From: Panop S. To: References: <000b01cbc1ed$902cb4d0$b0861e70$@vizrt.com> In-Reply-To: Subject: RE: Deleting Document Date: Wed, 2 Feb 2011 16:33:21 +0700 Message-ID: <001901cbc2bc$402ef310$c08cd930$@vizrt.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQD8W5nmiesjYmtrU0aPDsAKivxpFAIte86nlXtUZaA= Content-Language: en-us Hi,=20 Thanks for your suggestion, for bulk deletion let's say we = have 50000 in one parent. Is it good idea to load all at once with bulk deletion ? Or I need reduce number to on view like limit=3D1000 and = issue multiple requests.=20 Big Thanks Again, =20 =20 -----Original Message----- From: Zachary Zolton [mailto:zachary.zolton@gmail.com]=20 Sent: Tuesday, February 01, 2011 9:55 PM To: user@couchdb.apache.org Subject: Re: Deleting Document You could eliminate the recursion in your algorithms by storing an array = of ancestor ID in each of your documents. Then you could just write a by-ancestor view, like so: function(doc) { doc.ancestor_ids.forEach(function(id) { emit(id, null); }); } When it's time to delete a document, you just query this view for all = docs that share the ancestor's ID and delete the matching documents. Note that if you want to re-parent a doc you will also need to update = all its children in this scheme. For both of these operations you could consider using bulk doc updates: http://is.gd/M9aNkg Depending on your project's requirements, you may benefit by using a = graph database instead. Cheers, Zach On Tue, Feb 1, 2011 at 2:53 AM, Panop S. wrote: > Hi, > > > > =A0 =A0 I have design a document in couchdb like a tree file structure = as > > > > =A0 =A0 =A01 > > =A0 =A0 =A0|--2 > > =A0 =A0 =A0| =A0 =A0|--4 > > =A0 =A0 =A0| > > =A0 =A0 =A0|--3 > > > > =A0 =A0 =A0Doc id : 2 > > =A0 =A0 =A0Parent: 1 > > > > =A0 =A0 =A0Doc id : 3 > > =A0 =A0 =A0Parent: 1 > > > > =A0 =A0 =A0Doc id : 4 > > =A0 =A0 =A0Parent: 1 > > > > =A0 =A0 =A0So when I query I emit it by parent Id . > > =A0 =A0 =A0Then when get =A0/id/1 , I will get docid =3D =A02 ,3 > > > > =A0 =A0 So if I would like to delete 1 require 2 steps in C# = application=20 > by using recursive call. > > > > 1. =A0 =A0 =A0 querying /id/1 =A0and issue get command id =3D 2 =A0and = issue=20 > delete command id =3D 2 > > 2. =A0 =A0 =A0 querying /id/2 =A0and issue get command id =3D 4 =A0and = issue=20 > delete command id =3D 4 > > > > =A0 =A0The problem is if there are a lot of documents it is slow down=20 > performance by recursive in C# code > > and query by loading huge documents =A0and the others client request=20 > cannot process. > > > > =A0 =A0As I can think of now for a lot of document by using = =A0&limit=3Dsome=20 > number to reduce a lot of tons > > Of document to be load. > > > > =A0 =A0 =A0 And also Can I write some operation to delete indexed id = on=20 > javascript of couchdb ? if so, is this good idea ? > > =A0 =A0 =A0 =A0 =A0Any Idea ? > > > > Big Thanks, > > > > > > > >