diff --git a/src/ejabberd_sm_mnesia.erl b/src/ejabberd_sm_mnesia.erl index 735e92a8d..028f301ed 100644 --- a/src/ejabberd_sm_mnesia.erl +++ b/src/ejabberd_sm_mnesia.erl @@ -98,14 +98,11 @@ init([]) -> update_tables(), ejabberd_mnesia:create(?MODULE, session, [{ram_copies, [node()]}, - {attributes, record_info(fields, session)}]), + {attributes, record_info(fields, session)}, + {index, [usr,us]}]), ejabberd_mnesia:create(?MODULE, session_counter, [{ram_copies, [node()]}, {attributes, record_info(fields, session_counter)}]), - mnesia:add_table_index(session, usr), - mnesia:add_table_index(session, us), - mnesia:add_table_copy(session, node(), ram_copies), - mnesia:add_table_copy(session_counter, node(), ram_copies), mnesia:subscribe(system), {ok, #state{}}. diff --git a/src/mod_muc_mnesia.erl b/src/mod_muc_mnesia.erl index 9c55f5898..9c6ebf924 100644 --- a/src/mod_muc_mnesia.erl +++ b/src/mod_muc_mnesia.erl @@ -49,9 +49,9 @@ init(_Host, Opts) -> ejabberd_mnesia:create(?MODULE, muc_registered, [{disc_copies, [node()]}, {attributes, - record_info(fields, muc_registered)}]), - update_tables(MyHost), - mnesia:add_table_index(muc_registered, nick). + record_info(fields, muc_registered)}, + {index, [nick]}]), + update_tables(MyHost). store_room(_LServer, Host, Name, Opts) -> F = fun () -> diff --git a/src/mod_roster_mnesia.erl b/src/mod_roster_mnesia.erl index a1019823d..c05716b78 100644 --- a/src/mod_roster_mnesia.erl +++ b/src/mod_roster_mnesia.erl @@ -42,14 +42,14 @@ init(_Host, _Opts) -> ejabberd_mnesia:create(?MODULE, roster, [{disc_copies, [node()]}, - {attributes, record_info(fields, roster)}]), + {attributes, record_info(fields, roster)}, + {index, [us]}]), ejabberd_mnesia:create(?MODULE, roster_version, [{disc_copies, [node()]}, {attributes, - record_info(fields, roster_version)}]), - update_tables(), - mnesia:add_table_index(roster, us), - mnesia:add_table_index(roster_version, us). + record_info(fields, roster_version)}, + {index, [us]}]), + update_tables(). read_roster_version(LUser, LServer) -> US = {LUser, LServer}, diff --git a/src/mod_shared_roster_mnesia.erl b/src/mod_shared_roster_mnesia.erl index 9af004b31..702e27a09 100644 --- a/src/mod_shared_roster_mnesia.erl +++ b/src/mod_shared_roster_mnesia.erl @@ -47,9 +47,9 @@ init(_Host, _Opts) -> {attributes, record_info(fields, sr_group)}]), ejabberd_mnesia:create(?MODULE, sr_user, [{disc_copies, [node()]}, {type, bag}, - {attributes, record_info(fields, sr_user)}]), - update_tables(), - mnesia:add_table_index(sr_user, group_host). + {attributes, record_info(fields, sr_user)}, + {index, [group_host]}]), + update_tables(). list_groups(Host) -> mnesia:dirty_select(sr_group, diff --git a/src/mod_sip_registrar.erl b/src/mod_sip_registrar.erl index 646a39161..83cf77a0d 100644 --- a/src/mod_sip_registrar.erl +++ b/src/mod_sip_registrar.erl @@ -181,10 +181,8 @@ init([]) -> ejabberd_mnesia:create(?MODULE, sip_session, [{ram_copies, [node()]}, {type, bag}, - {attributes, record_info(fields, sip_session)}]), - mnesia:add_table_index(sip_session, conn_mref), - mnesia:add_table_index(sip_session, socket), - mnesia:add_table_copy(sip_session, node(), ram_copies), + {attributes, record_info(fields, sip_session)}, + {index, [conn_mref,socket]}]), {ok, #state{}}. handle_call({write, Sessions, Supported}, _From, State) -> diff --git a/src/mod_vcard_mnesia.erl b/src/mod_vcard_mnesia.erl index f1a70e20d..5faff5261 100644 --- a/src/mod_vcard_mnesia.erl +++ b/src/mod_vcard_mnesia.erl @@ -46,20 +46,13 @@ init(_Host, _Opts) -> ejabberd_mnesia:create(?MODULE, vcard_search, [{disc_copies, [node()]}, {attributes, - record_info(fields, vcard_search)}]), - update_tables(), - mnesia:add_table_index(vcard_search, luser), - mnesia:add_table_index(vcard_search, lfn), - mnesia:add_table_index(vcard_search, lfamily), - mnesia:add_table_index(vcard_search, lgiven), - mnesia:add_table_index(vcard_search, lmiddle), - mnesia:add_table_index(vcard_search, lnickname), - mnesia:add_table_index(vcard_search, lbday), - mnesia:add_table_index(vcard_search, lctry), - mnesia:add_table_index(vcard_search, llocality), - mnesia:add_table_index(vcard_search, lemail), - mnesia:add_table_index(vcard_search, lorgname), - mnesia:add_table_index(vcard_search, lorgunit). + record_info(fields, vcard_search)}, + {index, [ luser, lfn, lfamily, + lgiven, lmiddle, lnickname, + lbday, lctry, llocality, + lemail, lorgname, lorgunit + ]}]), + update_tables(). stop(_Host) -> ok. diff --git a/src/nodetree_tree.erl b/src/nodetree_tree.erl index 084c53d42..4d9b727b7 100644 --- a/src/nodetree_tree.erl +++ b/src/nodetree_tree.erl @@ -51,13 +51,8 @@ init(_Host, _ServerHost, _Options) -> ejabberd_mnesia:create(?MODULE, pubsub_node, [{disc_copies, [node()]}, - {attributes, record_info(fields, pubsub_node)}]), - mnesia:add_table_index(pubsub_node, id), - NodesFields = record_info(fields, pubsub_node), - case mnesia:table_info(pubsub_node, attributes) of - NodesFields -> ok; - _ -> ok - end, + {attributes, record_info(fields, pubsub_node)}, + {index, [id]}]), %% mnesia:transform_table(pubsub_state, ignore, StatesFields) ok.