pagination and mnesia

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

pagination and mnesia

Karlo Kuna
Hello, 

i was wandering was ti the best way to paginate mnesia table. Problem is hot to get N record from/or up to record X ? I'm interested in ways of doing that without qlc. 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: pagination and mnesia

Vance Shipley
On Mon, Jun 10, 2019 at 6:46 PM Karlo Kuna <[hidden email]> wrote:
> i was wandering was ti the best way to paginate mnesia table. Problem is hot to get N record from/or up to record X ? I'm interested in ways of doing that without qlc.

Use mnesia:select./4 which takes a Size argument and returns a Continuity.
The trick is to use an ets context, not a transaction.

Here's an example from one of our projects:
https://github.com/sigscale/rim/blob/master/src/im.erl#L167

--
     -Vance
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: pagination and mnesia

Karlo Kuna
Thank you Vance this is valuable example, 

how does Continuity holds up against changes in table between mnesia:select calls? 


On Mon, Jun 10, 2019 at 3:52 PM Vance Shipley <[hidden email]> wrote:
On Mon, Jun 10, 2019 at 6:46 PM Karlo Kuna <[hidden email]> wrote:
> i was wandering was ti the best way to paginate mnesia table. Problem is hot to get N record from/or up to record X ? I'm interested in ways of doing that without qlc.

Use mnesia:select./4 which takes a Size argument and returns a Continuity.
The trick is to use an ets context, not a transaction.

Here's an example from one of our projects:
https://github.com/sigscale/rim/blob/master/src/im.erl#L167

--
     -Vance

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: pagination and mnesia

Vance Shipley
On Mon, Jun 10, 2019 at 8:29 PM Karlo Kuna <[hidden email]> wrote:
> how does Continuity holds up against changes in table between mnesia:select calls?

It continues to work however don't expect the results to include new data.

--
     -Vance
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: pagination and mnesia

Karlo Kuna
thank you very much Vance

On Mon, Jun 10, 2019 at 5:18 PM Vance Shipley <[hidden email]> wrote:
On Mon, Jun 10, 2019 at 8:29 PM Karlo Kuna <[hidden email]> wrote:
> how does Continuity holds up against changes in table between mnesia:select calls?

It continues to work however don't expect the results to include new data.

--
     -Vance

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions