Speedup startup with many pubsub nodes (EJAB-669)

SVN Revision: 1490
This commit is contained in:
Christophe Romain 2008-07-25 09:06:09 +00:00
parent d9f3c87899
commit 782ee63266
3 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2008-07-25 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: Speedup startup with many pubsub
nodes (EJAB-669)
* src/mod_pubsub/nodetree_default.erl: Likewise
2008-07-24 Badlop <badlop@process-one.net>
* doc/guide.tex: Include example PAM configuration file

View File

@ -286,8 +286,7 @@ update_database(Host) ->
mnesia:delete_table(pubsub_node),
mnesia:create_table(pubsub_node,
[{disc_copies, [node()]},
{attributes, record_info(fields, pubsub_node)},
{index, [type, parentid]}]),
{attributes, record_info(fields, pubsub_node)}]),
lists:foreach(fun(Record) ->
mnesia:write(Record)
end, NewRecords)

View File

@ -70,8 +70,7 @@
init(_Host, _ServerHost, _Opts) ->
mnesia:create_table(pubsub_node,
[{disc_copies, [node()]},
{attributes, record_info(fields, pubsub_node)},
{index, [type,parentid]}]),
{attributes, record_info(fields, pubsub_node)}]),
NodesFields = record_info(fields, pubsub_node),
case mnesia:table_info(pubsub_node, attributes) of
[host_node, host_parent, info] -> ok; % old schema, updated later by pubsub
@ -114,7 +113,7 @@ get_nodes(Key) ->
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
get_subnodes(Host, Node) ->
mnesia:index_read(pubsub_node, {Host, Node}, #pubsub_node.parentid).
mnesia:match_object(#pubsub_node{parentid = {Host, Node}, _ = '_'}).
%% @spec (Host, Index) -> [pubsubNode()] | {error, Reason}
%% Host = mod_pubsub:host()