[erlang-questions] Efficiency of qlc

Solomon solomon.wzs@REDACTED
Tue Nov 20 03:18:15 CET 2012


I want to wirte a sql compiler for mnesia, so I need to dynamic compile the
query string by qlc:string_to_handle/1, but it is much slower than native
code. And I found that:

code 1:
*qlc:string_to_handle("[X||X<-[1,2,3]].")*
return:
*{qlc_handle,{qlc_lc,#Fun<erl_eval.20.82930912>,
                    {qlc_opt,false,false,-1,any,[],any,524288,allowed}}}*

code 2:
*qlc:q([X||X<-[1,2,3]])*
return:
*{qlc_handle,{qlc_lc,#Fun<my_module.0.234232>,
                    {qlc_opt,false,false,-1,any,[],any,524288,allowed}}}*

so I think the reason is that: code 1 run by erl_eval, it scan and parser
the code every time, and code 2 by beam, so code 1 was much slower than
code 2.
Is there any method to solve this problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121120/a8a64f84/attachment.htm>


More information about the erlang-questions mailing list