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 9FB75DF38 for ; Tue, 6 Nov 2012 08:16:23 +0000 (UTC) Received: (qmail 71117 invoked by uid 500); 6 Nov 2012 08:16:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 70918 invoked by uid 500); 6 Nov 2012 08:16:21 -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 70452 invoked by uid 99); 6 Nov 2012 08:16:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 08:16:19 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.220.180] (HELO mail-vc0-f180.google.com) (209.85.220.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 08:16:12 +0000 Received: by mail-vc0-f180.google.com with SMTP id fl13so147439vcb.11 for ; Tue, 06 Nov 2012 00:15:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding :x-gm-message-state; bh=mt9M3ui5SWn1oogVYio9ILrsNPQvag6rNYDBdd49F4g=; b=dDHuPHhQyDuIZ5NEktKTd2ph0TpMUHMcvx+xHZBT7YAA06K9QcSvx903xvM1uBy5B+ sv8MIdfr5yS28FH2I4mzdJCxlwIgas0NNRx9w4atCqqySUiMGUufi9Hp+L9DDO3fhECz YBpu2EQsT+IjFZLP8AUhzFiE/xJuQ4jQNqyeI38CgXZzP9pA6a55ccjuH64JAgbzsaQG pDSXn+aQOQr5HZw6jlsGLu1YqI8iDzGPOMHjgRMXYrlKZ8Yew+UBd6CMr+bCbyyrFzr2 /zPqu71WJz9ToHxzWHKV3D76CAFuZRkkcUwLu3RwYrDkRBoK15QksG/ZayU3rxtDR/Tn VSvg== MIME-Version: 1.0 Received: by 10.58.248.41 with SMTP id yj9mr185273vec.29.1352189751008; Tue, 06 Nov 2012 00:15:51 -0800 (PST) Received: by 10.58.92.98 with HTTP; Tue, 6 Nov 2012 00:15:50 -0800 (PST) X-Originating-IP: [84.112.19.176] In-Reply-To: <99EA19FD-5ED6-4EDA-B538-2D78DCE47DFF@charter.net> References: <99EA19FD-5ED6-4EDA-B538-2D78DCE47DFF@charter.net> Date: Tue, 6 Nov 2012 09:15:50 +0100 Message-ID: Subject: Re: Exist test? From: Dave Cottlehuber To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlAvE9YvnOsJWEsFYVWmGBSgDdOCFxFsg7vuf8wPI7hEPYe+cQ8bLcqspiur+Ymd41jBoQW X-Virus-Checked: Checked by ClamAV on apache.org On 5 November 2012 19:22, Kevin Burton wrote: > I am calling CreateDocument() but I suspect that testing if the= document exists first may perform better in the long run. I am using Dream= Seat for my driver but I suspect other drivers have a similar "test". My pr= oblem is that I don't know what to test for and I am unfamiliar with the av= ailable methods. Any one successfully use such a pattern (preferably with D= reamSeat) that tests for existence then creates if the document doesn't exi= st? Keep in mind I don't initially have an id. Thank you. > Hi Kevin, A number of folk have said "read the guide first" and it's sound advice http://guide.couchdb.org/draft/index.html as you're stuck with conceptual stuff that's well covered in the book. I recommend skipping the sofa chapter (it was written some time ago). Secondly, I recommend having a play at first with pure HTTP i.e. curl or similar. This is simply so you get a real feel for how your data is actually stored and manipulated, before layering an abstraction on top. It *will* save you time in the short run, and it's not scary. I learned a huge amount about HTTP itself along the way and I'm definitely not done yet/ So it's all good. You can also watch the HTTP calls in & out of futon using Chrome Debugger or some other proxy like CharlesProxy in between. I'm assuming you are using Windows (yay!) so http://wiki.apache.org/couchdb/Quirks_on_Windows has some tips on using curl successfully, and I'm happy to help out if you get stuck. Let me know if anything is not clear or out of date. If you're initially bulk uploading data, I would do 3 things differently to what you're currently doing. 1. assign UUIDs myself This is the only enforced unique indexed attribute in a DB, so use it well. Put something you want in it. It's basically free text ** within reason. 2. insert them in sorted UUID order CouchDB is a database and sorting matters. Couch uses a B~tree ** and so if you insert randomly you spend a lot of time forcing the re-write of intermediate nodes for no gain. As Couch is an append-only datastore this means several things - - wasted space until you compact - slower insert performance as you have multiple writes instead of one http://horicky.blogspot.co.at/2008/10/couchdb-implementation.html 3. try inserting the first few docs by hand with curl. And read up on the _bulk_docs API, this is much much faster. Re your drivers, there are several but I personally don't use any of them. There are more popular ones (based on my dodgy recollection) here http://wiki.apache.org/couchdb/Related_Projects hopefully some of the other Windows folk will pipe up. A+ Dave ** handwavey