[erlang-questions] How fast is to retrieve date from ETS table

Martin Dimitrov mrtndimitrov@REDACTED
Wed Jan 11 12:15:30 CET 2012

I thought this is a lame question so I posted it on StackOverflow
so not to bother the list but there aren't many replies.

Here it is my observation:

I know that lookup time is constant for ETS tables. But I also heard
that the table is kept outside of the process and when retrieving data,
the data needs to be moved to the process heap. So, this is expensive.
But then, how to explain this:

1> {ok, B} = file:read_file("IMG_2171.JPG").
2> size(B).
3> L = binary_to_list(B).
4> length(L).
5> ets:insert(utilo, {a, L}).
6> timer:tc(ets, match, [utilo, {a, '$1'}]).

It takes 106000 microseconds to retrieve 1986392 long list which is
pretty fast, isn't it?
I also tried it from a module and the result is the same.

Best regards,


More information about the erlang-questions mailing list