couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r710156 - /incubator/couchdb/trunk/src/couchdb/couch_view.erl
Date Mon, 03 Nov 2008 20:59:45 GMT
Author: damien
Date: Mon Nov  3 12:59:45 2008
New Revision: 710156

URL: http://svn.apache.org/viewvc?rev=710156&view=rev
Log:
Fix for performance problem with views. Every access to a view was causing a disk sync, regardless
if the index was updated.

Modified:
    incubator/couchdb/trunk/src/couchdb/couch_view.erl

Modified: incubator/couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_view.erl?rev=710156&r1=710155&r2=710156&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_view.erl Mon Nov  3 12:59:45 2008
@@ -382,7 +382,7 @@
 
 temp_update_loop(DbName, Group, NotifyPids) ->
     {ok, Db} = couch_db:open(DbName, []),
-    {ok, Group2} = update_group(Group#group{db=Db}),
+    {_Updated, Group2} = update_group(Group#group{db=Db}),
     couch_db:close(Db),
     [Pid ! {self(), {ok, Group2}} || Pid <- NotifyPids],
     garbage_collect(),
@@ -463,7 +463,10 @@
         couch_db:close(Db)
     end,
     case Result of
-    {ok, Group2} ->
+    {same, Group2} ->
+        [Pid ! {self(), {ok, Group2}} || Pid <- NotifyPids],
+        update_loop(RootDir, DbName, GroupId, Group2, get_notify_pids(100000));
+    {updated, Group2} ->
         HeaderData = {Sig, get_index_header_data(Group2)},
         ok = couch_file:write_header(Fd, <<$r, $c, $k, 0>>, HeaderData),
         [Pid ! {self(), {ok, Group2}} || Pid <- NotifyPids],
@@ -555,9 +558,9 @@
     couch_query_servers:stop_doc_map(Group4#group.query_server),
     if CurrentSeq /= NewSeq ->
         {ok, Group5} = write_changes(Group4, ViewKVsToAdd2, DocIdViewIdKeys2, NewSeq),
-        {ok, Group5#group{query_server=nil}};
+        {updated, Group5#group{query_server=nil}};
     true ->
-        {ok, Group4#group{query_server=nil}}
+        {same, Group4#group{query_server=nil}}
     end.
     
 delete_index_dir(RootDir, DbName) ->



Mime
View raw message