ETS retrieve all objects before deleting the table
Fri Jan 28 22:33:09 CET 2022
IIRC tab2file does basically this, fixtable -> select with limit and a
continuation which writes to the target file.
I'm pretty sure that if there were a quicker (and still "safe" way) to
do this, the code would be using that method.
On Fri, Jan 28, 2022 at 3:35 PM Jesper Louis Andersen
> 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.
More information about the erlang-questions