Re: ETS retrieve all objects before deleting the table

Frank Muller <[email protected]> Tue, 18 Jan 2022 08:46:14 +0100
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAFA6GnCLj9BLYh4g040DFwLgEDSEarnFLuzYPaMEt=cGVg-9ug@mail.gmail.com>
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

Is there a way to only retrieve keys from an ETS table?
/Frank


> On Mon, Jan 17, 2022 at 10:02 PM Frank Muller
> <[email protected]> wrote:
> >
> > Hey guys,
> >
> > Is there a way (documented or not) to retrieve all objects from an
> ordered_set table?
> >
> > I’d like to retrieve all objects before deleting the table.
> > What’s the most efficient way to do it?
> >
> > My table contains roughly ~1 million objects.
> > Objects are tuple: {non_neg_integer(), pos_integer()}
>
> ets:tab2list/1, or possibly ets:match_object/2 or ets:select/2 (I
> haven't benchmarked them).
> They are all documented.
>
> ($subject mentions ETS, so I assume this is about plain ETS and not
> Mnesia ram_copies or something like that.)
>