I want to wirte a sql compiler for mnesia, so I need to <span id="result_box" class="" lang="en"><span class="">dynamic compile the query string by qlc:string_to_handle/1, but it is much slower than native code. And I found that:<br>
<br>code 1:<br><i>qlc:string_to_handle("[X||X<-[1,2,3]].")</i><br>return:<br><i>{qlc_handle,{qlc_lc,#Fun<<b>erl_eval</b>.20.82930912>,<br>                    {qlc_opt,false,false,-1,any,[],any,524288,allowed}}}</i><br>
<br>code 2:<br><i>qlc:q([X||X<-[1,2,3]])</i><br>return:<br><i>{qlc_handle,{qlc_lc,#Fun<<b>my_module</b>.0.234232>,<br>                    {qlc_opt,false,false,-1,any,[],any,524288,allowed}}}</i><br><br>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.<br>
Is there any </span></span>method to solve this problem?<br>