[erlang-questions] qlc cursor offset

Alain O'Dea alain.odea@REDACTED
Wed Dec 29 03:28:55 CET 2010


I didn't measure beyond seeing if user-visible lag increased with the amount of data being paged.  It didn't as far as I could perceive.



On 2010-12-28, at 14:13, Andre Nathan <andre@REDACTED> wrote:

> On Tue, 2010-12-28 at 12:48 -0330, Alain O'Dea wrote:
>> I code-shopped Paul Mineiro's solution when I needed to do efficient
>> pagination with Mnesia like this for scrumjet:
> 
> Doesn't this solution simply fetch and drop all results until the offset
> is reached? Is it better in terms of performance than the code below?
> 
> limit(Table, Offset, Number) ->
>  TH = qlc:keysort(2, mnesia:table(Table)),
>  QH = qlc:q([Q || Q <- TH]),
>  QC = qlc:cursor(QH),
>  %% Drop initial resuls. Handling of Offset =:= 0 not shown.
>  qlc:next_answers(QC, Offset - 1),
>  Results = qlc:next_answers(QC, Number),
>  qlc:delete_cursor(QC),
>  Results.
> 
> Thanks,
> Andre
> 


More information about the erlang-questions mailing list