Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 47864 invoked from network); 7 Oct 2009 01:19:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Oct 2009 01:19:54 -0000 Received: (qmail 36741 invoked by uid 500); 7 Oct 2009 01:19:53 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 36667 invoked by uid 500); 7 Oct 2009 01:19:53 -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 36657 invoked by uid 99); 7 Oct 2009 01:19:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2009 01:19:53 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of adam.kocoloski@gmail.com designates 209.85.221.179 as permitted sender) Received: from [209.85.221.179] (HELO mail-qy0-f179.google.com) (209.85.221.179) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2009 01:19:44 +0000 Received: by qyk9 with SMTP id 9so8042598qyk.30 for ; Tue, 06 Oct 2009 18:19:23 -0700 (PDT) Received: by 10.224.102.194 with SMTP id h2mr2050006qao.96.1254878363048; Tue, 06 Oct 2009 18:19:23 -0700 (PDT) Received: from ?10.0.1.9? (c-71-232-49-44.hsd1.ma.comcast.net [71.232.49.44]) by mx.google.com with ESMTPS id 5sm39289qwg.43.2009.10.06.18.19.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Oct 2009 18:19:22 -0700 (PDT) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1076) Subject: Re: couchdb slowed down From: Adam Kocoloski In-Reply-To: Date: Tue, 6 Oct 2009 21:19:20 -0400 Content-Transfer-Encoding: 7bit Message-Id: References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1076) X-Virus-Checked: Checked by ClamAV on apache.org On Oct 6, 2009, at 5:18 PM, Norman Barker wrote: > I have upgraded couchdb from 0.9 to the trunk and the document write > speed has really slowed down. > > My sequence is to call an erlang function get_docs_revs (my code) to > find if the document exists as follows > > get_doc_revs(Db, DocId) -> > case DocId of > undefined -> > Id = couch_util:new_uuid(), > Revs = {0, []}; > _ -> > case couch_db:get_doc_info(Db, DocId) of > {ok, Info} -> > Id = Info#doc_info.id, > [{rev_info, {Start, Rev}, _seq, _deleted, _body_sp}|_] = > Info#doc_info.revs, > Revs = {Start, [Rev]}; > _ -> > Id = DocId, > Revs = {0, []} > end > end, > {Id, Revs}. > > and then to write this doc to couch by calling write_doc_to_couch(Db, > #doc{id=Id, revs=Revs, body={JsonObj}}, []) where this is defined as; > > write_doc_to_couch(Db, Doc, Options) -> > case couch_db:update_doc(Db, Doc, Options) of > {ok, NewRev} -> > {Doc#doc.id, NewRev}; > Error -> > throw({error, Error}) > end. > > With this sequence I was writing about 500 docs in 5 seconds with 0.9, > now it has slowed down to 30 seconds with trunk, my JSON generating > code hasn't changed at all, the only thing that has had to change > since moving from 0.9 to trunk is the get_docs_revs above - has this > become a bottle neck in couchdb? > > My temporary work around is to spawn the writes, but this still > doesn't really solve why it is has slowed down so much. Is there a > 'cheaper' way of getting the current revision? > > thanks, > > Norman Hi Norman, you might check the value for delayed_commits in the [couchdb] section of the .ini files. If set to false your serial write performance will be slower because CouchDB will fsync before returning from update_doc/3. If set to true CouchDB will fsync at most once per second. It's a tradeoff between durability and throughput. For a while delayed_commits was set to false on trunk. Best, Adam