[erlang-questions] Question: Limiting size of result set in mnesia
Jani Launonen
launoja@REDACTED
Mon Apr 28 14:35:08 CEST 2008
----- Alkuperäinen viesti -----
Lähettäjä: Ahmed Ali <ahmed.nawras@REDACTED>
Päiväys: maanantai, huhtikuu 28, 2008 3:21 pm
Aihe: [erlang-questions] Question: Limiting size of result set in mnesia
Vastaanottaja: "Erlang-Questions (E-mail)" <erlang-questions@REDACTED>
>
> Hi All,
>
> Does anyone have an idea of how to limit size of result set in mnesia
> similar to the effect of LIMIT clause in the SQL query below in MySQL?
>
> SELECT * FROM Topic LIMIT 5;
>From Mnesia Reference Manual (http://www.erlang.org/doc/man/mnesia.html) :
"select(Tab, MatchSpec, NObjects, Lock) -> transaction abort | {[Object],Cont} | '$end_of_table'
Matches the objects in the table Tab using a match_spec as described in ERTS users guide, and returns a chunk of terms and a continuation, the wanted number of returned terms is specified by the NObjects argument. The lock argument can be read or write. The continuation should be used as argument to mnesia:select/1, if more or all answers are needed.
Note: for best performance select should be used before any modifying operations are done on that table in the same transaction, i.e. don't use mnesia:write or mnesia:delete before a mnesia:select. For efficiency the NObjects is a recommendation only and the result may contain anything from an empty list to all available results.
select(Cont) -> transaction abort | {[Object],Cont} | '$end_of_table'
Selects more objects with the match specification initiated by mnesia:select/4.
Note: Any modifying operations, i.e. mnesia:write or mnesia:delete, that are done between the mnesia:select/4 and mnesia:select/1 calls will not be visible in the result.
"
Cheers,
Jani Launonen
> Best regards,
>
> Ahmed Al-Issaei
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list