Skip to content

Commit 2ea133b

Browse files
Merge branch 'sylvainhubsch-rabbitmq-server-match-bindings-optimize'
2 parents f6745af + 457caee commit 2ea133b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/rabbit_router.erl

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,12 @@
3636

3737
%%----------------------------------------------------------------------------
3838

39-
%% TODO: Maybe this should be handled by a cursor instead.
40-
%% TODO: This causes a full scan for each entry with the same source
4139
match_bindings(SrcName, Match) ->
42-
Query = qlc:q([DestinationName ||
43-
#route{binding = Binding = #binding{
44-
source = SrcName1,
45-
destination = DestinationName}} <-
46-
mnesia:table(rabbit_route),
47-
SrcName == SrcName1,
48-
Match(Binding)]),
49-
mnesia:async_dirty(fun qlc:e/1, [Query]).
40+
MatchHead = #route{binding = #binding{source = SrcName,
41+
_ = '_'}},
42+
Routes = ets:select(rabbit_route, [{MatchHead, [], [['$_']]}]),
43+
[Dest || [#route{binding = Binding = #binding{destination = Dest}}] <-
44+
Routes, Match(Binding)].
5045

5146
match_routing_key(SrcName, [RoutingKey]) ->
5247
find_routes(#route{binding = #binding{source = SrcName,

0 commit comments

Comments
 (0)