ETS retrieve all objects before deleting the table

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Fri Jan 28 21:34:52 CET 2022


On Tue, Jan 18, 2022 at 8:46 AM Frank Muller <frank.muller.erl@REDACTED>
wrote:

> Hi Mikael,
>
> I  tried them all before posting here.
>
> From fastest to slowest:
> 1. select/2 (stable numbers)
> 2. match_object/2
> 3. first/1 + next/2
> 4. tab2list
>
>
You also need to consider memory usage. When you copy a potentially large
ETS table into the heap of a process, you risk blowing up if the table is
large. I'd probably safe_fixtable/2 on the table, traverse it with
match_object/3 1000 elems at a time or so, then remove the fix when
$end_of_table is reached. If any kind of disk I/O is involved, you are
likely to be I/O bound on the disk anyway, or your serialization scheme is
what is going to slow you down. But because of the table fix, you should be
able to work on the disk set in a stable manner.

Clearly, there's some consideration w.r.t if the serialization has to "stop
the world" until the table is on disk. Working around that would be my main
concern.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20220128/559c5a66/attachment.htm>


More information about the erlang-questions mailing list