[erlang-questions] qlc cursor offset
Tue Dec 28 18:43:17 CET 2010
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),
More information about the erlang-questions