summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-11-03 20:59:45 +0000
committerDamien F. Katz <damien@apache.org>2008-11-03 20:59:45 +0000
commit60bc407c5fc00acc1d0608a45693b8cc61b21d79 (patch)
tree757e7c206629d134716c64d44c0e5b843d42e15d /src
parentc4457a1d1907159d5948c4994009fd60ad337473 (diff)
Fix for performance problem with views. Every access to a view was causing a disk sync, regardless if the index was updated.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@710156 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_view.erl11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index e3623dde..4ebbb136 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -382,7 +382,7 @@ start_temp_update_loop(DbName, Fd, Lang, MapSrc, RedSrc) ->
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 @@ update_loop(RootDir, DbName, GroupId, #group{sig=Sig,fd=Fd}=Group, NotifyPids) -
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 @@ update_group(#group{db=Db,current_seq=CurrentSeq,
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) ->