[erlang-questions] dict vs. ETS choice

zxq9 zxq9@REDACTED
Thu Jul 10 22:56:25 CEST 2014

On Thursday 10 July 2014 14:29:42 Derek Brown wrote:
> Let's say you want to store on the order of tens of thousands key/value
> pairs, with integer keys and proplist values (less than 10 simple key/value
> pairs per proplist). Read-heavy with few writes.
> What factors would you consider when going with a dict or an ETS table, or
> perhaps something else?

Factors to consider? Whatever benchmarking both cases tells me. I would run 
each test case alongside a few different workloads on the same machine to 
figure out what good/bad things to expect from each approach.

Someone will probably come along who actually has done this both ways and tell 
you there is indeed a Right Way, but usually I've found that taking the time 
to run some informal benchmarks provides more insight (which winds up useful 
elsewhere) than adherence to advice/data structure guidelines. Also, data 
structure advice often turns out to be a wordy version of "it depends..." and 
then a request for more information about the higher level problem you're 
actually trying to solve.

What is the overall effect you're trying to achieve? It would be helpful to 
spell out the problem you're trying to solve (at the higher level like "how to 
best store 100k player's stats at once" instead of at the implementation 
detail of "is a dict or an ETS table better for 100k values?"). Very often 
you'll find someone has already tackled something similar and can give you 
some good advice you'd never get when asking just about the details of data 
structures. This prevents X->Y problem discussions.

More information about the erlang-questions mailing list