aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-05-17 10:03:30 +0200
committerFredrik Gustafsson <[email protected]>2013-05-17 10:03:30 +0200
commita70d09b6e611771b467a91c7ebeca1e14390553a (patch)
tree850802a816adc4739acea355d5cbd9d5707231fd
parent8260029bfd36d4bfb78411643017db1c4991757c (diff)
parentfb8cbfa5db65f4bb9dcb133de9414c78aa49d9e7 (diff)
downloadotp-a70d09b6e611771b467a91c7ebeca1e14390553a.tar.gz
otp-a70d09b6e611771b467a91c7ebeca1e14390553a.tar.bz2
otp-a70d09b6e611771b467a91c7ebeca1e14390553a.zip
Merge branch 'nm/mnesia_idx_insert_speedup/OTP-11103' into maint
* nm/mnesia_idx_insert_speedup/OTP-11103: Fix missing case clause for ordered_set tables Optimize index creation for Mnesia set tables
-rw-r--r--lib/mnesia/src/mnesia_index.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/mnesia/src/mnesia_index.erl b/lib/mnesia/src/mnesia_index.erl
index f9f3ce2ea4..6f9f575d93 100644
--- a/lib/mnesia/src/mnesia_index.erl
+++ b/lib/mnesia/src/mnesia_index.erl
@@ -301,7 +301,13 @@ make_ram_index(Tab, [Pos | Tail]) ->
add_ram_index(Tab, Pos) when is_integer(Pos) ->
verbose("Creating index for ~w ~n", [Tab]),
- Index = mnesia_monitor:mktab(mnesia_index, [bag, public]),
+ SetOrBag = val({Tab, setorbag}),
+ IndexType = case SetOrBag of
+ set -> duplicate_bag;
+ ordered_set -> duplicate_bag;
+ bag -> bag
+ end,
+ Index = mnesia_monitor:mktab(mnesia_index, [IndexType, public]),
Insert = fun(Rec, _Acc) ->
true = ?ets_insert(Index, {element(Pos, Rec), element(2, Rec)})
end,
@@ -309,7 +315,7 @@ add_ram_index(Tab, Pos) when is_integer(Pos) ->
true = ets:foldl(Insert, true, Tab),
mnesia_lib:db_fixtable(ram_copies, Tab, false),
mnesia_lib:set({Tab, {index, Pos}}, Index),
- add_index_info(Tab, val({Tab, setorbag}), {Pos, {ram, Index}});
+ add_index_info(Tab, SetOrBag, {Pos, {ram, Index}});
add_ram_index(_Tab, snmp) ->
ok.