Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The statement <code>Fastest Way</code> to <code>return more than 5000 rows</code> depends on the problem in question. What is the database structure ? What do we want ? what is the record structure ? After those, then, it boils down to how you write your read functions. If we are sure about the primary key, then we use <code>mnesia:read/1 or mnesia:read/2</code> if not, its better and more beautiful to use <a href="http://www.erlang.org/doc/man/qlc.html" rel="nofollow"><b>Query List comprehensions</b></a>. Its more flexible to search nested records and with complex conditional queries. see usage below:</p> <pre> -include_lib("stdlib/include/qlc.hrl"). -record(bigdata, {mykey,some1,some2}). %% query list comprehenshions select(Q)-&gt; %% to prevent against nested transactions %% to ensure it also works whether table %% is fragmented or not, we will use %% mnesia:activity/4 case mnesia:is_transaction() of false -&gt; F = fun(QH)-&gt; qlc:e(QH) end, mnesia:activity(transaction,F,[Q],mnesia_frag); true -&gt; qlc:e(Q) end. %% to read by a given field or even several %% you use a list comprehension and pass the guards %% to filter those records accordingly read_by_field(some2,Value)-&gt; QueryHandle = qlc:q([X || X &lt;- mnesia:table(bigdata), X#bigdata.some2 == Value]), select(QueryHandle). %% selecting by several conditions read_by_several()-&gt; %% you can pass as many guard expressions QueryHandle = qlc:q([X || X &lt;- mnesia:table(bigdata), X#bigdata.some2 =&lt; 300, X#bigdata.some1 &gt; 50 ]), select(QueryHandle). %% Its possible to pass a 'fun' which will do the %% record selection in the query list comprehension auto_reader(ValidatorFun)-&gt; QueryHandle = qlc:q([X || X &lt;- mnesia:table(bigdata), ValidatorFun(X) == true]), select(QueryHandle). read_using_auto()-&gt; F = fun({bigdata,SomeKey,_,Some2}) -&gt; true; (_) -&gt; false end, auto_reader(F). </pre> <p>So i think if you want fastest way, we need more clarification and problem detail. Speed depends on many factors my dear ! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload