ets: Erlang Term Storage. It is a set of Erlang built in functions (BIF) that aims to provide a way to store in memory a large amount of data with constant access time. The data is stored as {Key,Value} tuples where both Key an Value may be any Erlang terms. It can be configured as ordered set, set, bag or duplicate_bag.
Questions tagged [ets]
159 questions
20
votes
1 answer
Erlang: optimize complex qlc
I have qlc
RefsBlocked = qlc:e(qlc:q([
Ref1 ||
{{Ref1, {pattern, {_Status1, _Pattern1, Limit1}}}, Count} <- dict:to_list(
qlc:fold(
fun({Key, _Ref2}, Acc) ->
dict:update_counter(Key, 1, Acc)
…

trytrytry
- 373
- 2
- 6
15
votes
3 answers
Erlang ETS tables versus message passing: Optimization concerns?
I'm coming into an existing (game) project whose server component is written entirely in erlang. At times, it can be excruciating to get a piece of data from this system (I'm interested in how many widgets player 56 has) from the process that owns…

Sniggerfardimungus
- 11,583
- 10
- 52
- 97
13
votes
1 answer
gen_server with a dict vs mnesia table vs ets
I'm building an erlang server.
Users sends http requests to the server to update their status.
The http request process on the server saves the user status message in memory.
Every minute the server sends all messages to a remote server and clear…

pablo
- 2,719
- 11
- 49
- 67
11
votes
1 answer
which is more efficent among ets and mnesia
ets:select vs mnesia:select
Which is better to use.And also in case of insertion and deletion which one of these two we should use.I am working on ejabberd.Any pointers?

Geek
- 698
- 1
- 6
- 25
10
votes
3 answers
Speed-up and best practices: Using ets for per-module pre-computed data
((Please forgive me that I ask more than one question in a single thread. I think they are related.))
Hello, I wanted to know, what best practices exist in Erlang in regards to per-module precompiled data.
Example: I have a module that heavily…

Kijewski
- 25,517
- 12
- 101
- 143
9
votes
3 answers
How to match ets:match against a record in Erlang?
I have heard that specifying records through tuples in the code is a bad practice: I should always use record fields (#record_name{record_field = something}) instead of plain tuples {record_name, value1, value2, something}.
But how do I match the…

skanatek
- 5,133
- 3
- 47
- 75
8
votes
4 answers
How to check if a named table exists or not in ETS Erlang/Elixir
I want to create a table in ets if it does not exists . How can I check if this named exists or not ?

Arun Dhyani
- 89
- 1
- 3
8
votes
2 answers
How to identify the exact memory size of an ETS table?
Give an ETS table with data, the info/1 function returns various properties for the table, including a size value which is specific to the number of rows rather than the physical size.
Is there any way to calculate the amount of memory in bytes…

gextra
- 8,439
- 8
- 40
- 62
8
votes
2 answers
Erlang/ets: reset ets table after getting a "bad argument"?
I've been learning how to use ets, but one thing that has bothered me is that, occasionally*, ets:match throws a bad argument… And, from them on, all subsequent calls (even calls which previously worked) also throw a bad argument:
> ets:match(Tid,…

David Wolever
- 148,955
- 89
- 346
- 502
7
votes
2 answers
Limit the growth of ETS storage
I'm considering using Erlang's ETS as a cache for user searches in a new Elixir project. Based on user input, the system will do lookups using an expensive third-party API.
In order to avoid making duplicate calls for the same user input, I intend…

Ben Coppock
- 939
- 11
- 23
6
votes
1 answer
Slowdowns of performance of ets select
I did some tests around performance of selection from ets tables and noted weird behaviour. For example we have a simple ets table (without any specific options) which stores key/value - a random string and a number:
:ets.new(:table,…

0xAX
- 20,957
- 26
- 117
- 206
6
votes
1 answer
How to update a number inside a tuple stored in an ets table?
Suppose I have an ets table like:
I = ets:new(mytable, [named_table, set]).
ets:insert(I, {10,{10, 4 ,"description"}).
I would like to update the element 4 using the ets:update_counter.
I tried in different way, but can't find the solution, for…

J.R.
- 2,335
- 2
- 19
- 21
6
votes
3 answers
How to retrieve a list of ets keys without scanning entire table?
I'm using ets via elixir as a simple in-memory persistence layer to store and retrieve keys and also for the occasional foldl which involves reducing many duplicate keys that have different values. I am using the bag option.
Is there a simple,…

bibekp
- 101
- 1
- 5
6
votes
3 answers
How should I auto-expire entires in an ETS table, while also limiting its total size?
I have a lot of analytics data which I'm looking to aggregate every so often (let's say one minute.) The data is being sent to a process which stores it in an ETS table, and every so often a timer sends it a message to process the table and remove…

Jakub Arnold
- 85,596
- 89
- 230
- 327
6
votes
1 answer
What is the best distributed Erlang in-memory cache?
I need some suggestion for the erlang in-memory cache system.
The cache item is key-value based storage.
key is usually an ASCII string; value is erlang's types include number / list / tuple / etc.
The cache item can be set by any of the node.
The…

Mr.Wang from Next Door
- 13,670
- 12
- 64
- 97