[erlang-questions] QLC vs mnesia:select/read

Hans Bolinder <>
Fri Jan 9 10:25:08 CET 2009


[Ryan Lepidi:]
> I am just learning Erlang and was recently reading up on the Mnesia section.
> It seems that QLC commands and the mnesia:select and mnesia:read functions
> do the same thing. Are there any drawbacks, functionality wise or speed
> wise, to using one over the other? Because to me it seems that QLC is
> simpler and more readable. Is it just a matter of preference?

mnesia:select() is more general than mnesia:read() as it takes match
specifications as arguments. Matchspecs are described in the ERTS
user's guide. There is a pseudo function ets:fun2ms() that makes is
easier to write matchspecs. See also ms_transform(3).

qlc translates queries to mnesia:{index_}read() or mnesia:select()
when possible, but there is an overhead at the beginning of the
evaluation of a query which makes qlc somewhat slower.

qlc is more general than matchspecs as filters can be any Erlang
expressions and data from several tables can be tested and combined
easily.

Best regards,

Hans Bolinder, Erlang/OTP team, Ericsson



More information about the erlang-questions mailing list