[erlang-questions] Question: Limiting size of result set in mnesia

Ahmed Ali ahmed.nawras@REDACTED
Tue Apr 29 08:19:48 CEST 2008


Thanks All. Now it is more clear to me.

On Mon, Apr 28, 2008 at 10:38 PM, Ulf Wiger <ulf@REDACTED> wrote:
> When selecting over a very large set, you may want QLC to retrieve
>  the data in chunks. Then, n_elements can be used to instruct the
>  table generators to return only a number of elements at a time.
>  This is something that might specify when implementing a QLC
>  table generator, I think.
>
>  This can have a beneficial effect on garbage collection, as the
>  process may be able to perform the work with a fairly small
>  heap. In simple queries (no joins or complex filter expressions),
>  it's not likely to help much, but it can improve memory
>  characteristics in some cases.
>
>  BR,
>  Ulf W
>
>  2008/4/28 Ahmed Ali <ahmed.nawras@REDACTED>:
>
>
> > Hi Hynek,
>  >
>  >  Thanks for the clarification. However, I still don't understand what's
>  >  the point of  n_elements in qlc:info(Q,[{n_elements,N}]). In QLC
>  >  documentation, it names 2 kinds of options, "Option = EvalOption |
>  >  ReturnOption" which suggests that qlc:info/2 can be used to set
>  >  evaluation time options.
>  >
>  >  Also, I'm assuming I can remove {unique, true} option from
>  >  qlc:append/2 and the result is still the same.
>  >
>  >
>  >  Best regards,
>  >
>  >  Ahmed Al-Issaei
>  >
>  >
>  >
>  > On Mon, Apr 28, 2008 at 5:26 PM, Hynek Vychodil
>  >  <vychodil.hynek@REDACTED> wrote:
>  >  > No, qlc:info just returns info. You should use cursor and next_answers.
>  >  >
>  >  > Just from documentation:
>  >  > C = qlc:cursor(qlc:q([X || X <- qlc:append(QH1, QH2)],{unique,true})),
>  >  > R = qlc:next_answers(C, 5),
>  >  > ok = qlc:delete_cursor(C),
>  >  >
>  >  > R.
>  >  >
>  >  >
>  >  >
>  >  > On Mon, Apr 28, 2008 at 2:42 PM, Ahmed Ali <ahmed.nawras@REDACTED> wrote:
>  >  > > Thanks Hynek and Kenneth for the quick response.
>  >  > >
>  >  > > Just to confirm, for qlc, I should write the query first and then run
>  >  > > qlc:info/2 on it in order to do the limiting, as the example below
>  >  > > shows. Is this it?
>  >  > >
>  >  > > e.g.:
>  >  > > Q = qlc:q(...),
>  >  > > qlc:info(Q, [{n_elements, 5}]
>  >  > >
>  >  > >
>  >  > > Best regards,
>  >  > >
>  >  > > Ahmed Al-Issaei
>  >  > >
>  >  > >
>  >  > >
>  >  > >
>  >  > > On Mon, Apr 28, 2008 at 4:32 PM, Kenneth Lundin
>  >  > > <kenneth.lundin@REDACTED> wrote:
>  >  > > > Hi,
>  >  > > >
>  >  > > >  You can use qlc
>  >  > > >  http://www.erlang.org/doc/man/qlc.html
>  >  > > >   or you can use
>  >  > > >  mnesia:select/4 in combination with mnesia:select/1
>  >  > > >  http://www.erlang.org/doc/man/mnesia.html#select-4
>  >  > > >
>  >  > > >  /Kenneth Erlang/OTP, Ericsson
>  >  > > >
>  >  > > >
>  >  > > >
>  >  > > >
>  >  > > >  On 4/28/08, Ahmed Ali <ahmed.nawras@REDACTED> wrote:
>  >  > > >  > 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;
>  >  > > >  >
>  >  > > >  > Best regards,
>  >  > > >  >
>  >  > > >  > Ahmed Al-Issaei
>  >  > > >
>  >  > > >
>  >  > > > > _______________________________________________
>  >  > > >  > erlang-questions mailing list
>  >  > > >  > erlang-questions@REDACTED
>  >  > > >  > http://www.erlang.org/mailman/listinfo/erlang-questions
>  >  > > >  >
>  >  > > >
>  >  > > _______________________________________________
>  >  > > erlang-questions mailing list
>  >  > > erlang-questions@REDACTED
>  >  > > http://www.erlang.org/mailman/listinfo/erlang-questions
>  >  > >
>  >  >
>  >  >
>  >  >
>  >  > --
>  >  > --Hynek (Pichi) Vychodil
>  >  _______________________________________________
>  >  erlang-questions mailing list
>  >  erlang-questions@REDACTED
>  >  http://www.erlang.org/mailman/listinfo/erlang-questions
>  >
>



More information about the erlang-questions mailing list