[erlang-questions] Get a range of tuples from a Mnesia table

Greg Burri <>
Sat Oct 4 18:19:53 CEST 2008


Hi,
I want to retrieve N tuple with an offset O from the end of a table. N and O
are integer(). I consider that the acces is based on an ordered table.

Here is an example, I have such tuples in my table t :
[{t, 1, _},
{t, 2, _},
{t, 3, _},
{t, 4, _},
{t, 5, _},
{t, 6, _},
{t, 7, _}]

For N=2 and O=3 the result will be :
[{t, 4, _}, {t, 5, _}]

For now I have to use an ordered_set table and the functions mnesia:last/1
and mnesia:prev/2, it works but the complexity is O(O). If I have to get
some tuple from the middle of the table it will take long time.
Is there an another solution than mine ?

Second question : How change the type of a table from set to ordered_set on
an existing table ?


/Greg Burri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081004/9eb64d2e/attachment.html>


More information about the erlang-questions mailing list