<div dir="auto">Sorry for being unclear. </div><div dir="auto"><br></div><div dir="auto">Mikael: yes, it’s plain ETS ordered_set table.</div><div dir="auto">Fred: I’m used to match spec and as I you’ve shown, it’s pretty easy to extract the keys. But it’s still slow: ~90millisec for 1M integer keys on my laptop. </div><div dir="auto"><br></div><div dir="auto">I’m looking for non-documented ways or tricks not found in the doc :-)</div><div dir="auto"><br></div><div dir="auto">Any other tip?</div><div dir="auto"><br></div><div dir="auto">/Frank</div><div><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><br>Hi Frank<br>
<br>
For the select/2 and match_object/2 choices you should be able to use a match_spec such as the following:<br>
<br>
{ {'$1', '$2'}, [], {'$1'} }<br>
<br>
The first element matches your two element ETS object, the third returns the first element only, assuming that's the key.<br>
<br>
Cheers,<br>
Fred<br>
<br>
On 18/01/2022 07:46, Frank Muller wrote:<br>
> Hi Mikael,<br>
> <br>
> I  tried them all before posting here.<br>
> <br>
>  From fastest to slowest:<br>
> 1. select/2 (stable numbers)<br>
> 2. match_object/2<br>
> 3. first/1 + next/2<br>
> 4. tab2list<br>
> <br>
> Is there a way to only retrieve keys from an ETS table?<br>
> /Frank<br>
> <br>
> <br>
>     On Mon, Jan 17, 2022 at 10:02 PM Frank Muller<br>
>     <<a href="mailto:frank.muller.erl@gmail.com" target="_blank">frank.muller.erl@gmail.com</a> <mailto:<a href="mailto:frank.muller.erl@gmail.com" target="_blank">frank.muller.erl@gmail.com</a>>> wrote:<br>
>      ><br>
>      > Hey guys,<br>
>      ><br>
>      > Is there a way (documented or not) to retrieve all objects from an ordered_set table?<br>
>      ><br>
>      > I’d like to retrieve all objects before deleting the table.<br>
>      > What’s the most efficient way to do it?<br>
>      ><br>
>      > My table contains roughly ~1 million objects.<br>
>      > Objects are tuple: {non_neg_integer(), pos_integer()}<br>
> <br>
>     ets:tab2list/1, or possibly ets:match_object/2 or ets:select/2 (I<br>
>     haven't benchmarked them).<br>
>     They are all documented.<br>
> <br>
>     ($subject mentions ETS, so I assume this is about plain ETS and not<br>
>     Mnesia ram_copies or something like that.)<br>
> <br>
</blockquote></div></div>