incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Norman Barker <>
Subject couchdb slowed down
Date Tue, 06 Oct 2009 21:18:16 GMT
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 =,
           [{rev_info, {Start, Rev}, _seq, _deleted, _body_sp}|_] =
           Revs = {Start, [Rev]};
        _ ->
          Id = DocId,
          Revs = {0, []}
  {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} ->
         {, NewRev};
      Error ->
         throw({error, Error})

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?



View raw message