How big is the overhead of a Mnesia table?

ecto
mnesia
distributed-database

#1

I’m building an application in which at some point in the near future we’d like to use the distributed features of Mnesia. However, since this is a chat application and there is little use for e.g. cross-channel searching capabilities, I’ve been thinking about the best structure for the tables.

It might make sense to create a table per channel, since common search-operations only happen in one channel, (so then we do not have to filter 99% of the messages because they are not of interest since they are from another channel right away).

In a more general sense: if you have structured data, fields that (together) uniquely identify groups of data that do not often need to be considered together, might be used as (part of the) table name instead, right?

However: Creating a new Mnesia table might itself have some overhead. How large is this? When does it make sense to split tables into more, smaller ones?


#2

Mnesia is just some wrappers around some ETS tables and I think a GenServer, so it is ETS and a GenServer.


#3

So that basically means: Very small, right? :slight_smile:


#4

As long as it is remembered that the system only supports a few thousand ETS tables (configurable via a command line argument as I recall?). :slight_smile:

But yes, very small. ^.^

Even the mnesia calls just delegate to the ets calls for in-memory tables, it’s that simple. :slight_smile:


#5

ERL_MAX_ETS_TABLES. This limit can easily be reached when using mnesia. I think mnesia uses temporary ets tables as well so it is not just about static tables.

I don’t think there are any considerable drawbacks to increase this by quite a margin.

iex(1)> :erlang.system_info(:ets_limit)
2053