What's the difference between ets tables `public`` named` and` local` and `ram_copy` mnesia

I am creating mnesia table like

mnesia:create_table(mytable, [{ram_copies, node()}, {local_content,true}], 
                              {attributes, [col1,col2]}]).

      

Because local_content=true

, so it cannot communicate with other nodes, and this is a table ram_copies

.

I believe I can do the same with the ets table as below.

ets:new(mytable,[named_table, public]).

      

I think they are similar in terms of performance.

I am wondering what are the differences between the two tables, in terms of semantics?

+3


source to share


1 answer


The table is in the background for storage. The difference is in the transaction processing supported by Mnesia, but not by ETS.

The actual processing of Mnesia transactions depends on the context used:



  • transaction

    : Perform a series of database operations as a single functional block. The whole block will work on all nodes or none of them; he succeeds entirely or fails completely. This type of activity context is partially asynchronous: it will be synchronous for operations on the local node, but it will wait for confirmation from other nodes that they will commit a transaction, not that they did.
  • sync_transaction

    : almost the same as transaction

    but it is synchronous for all nodes.
  • async_dirty

    : bypasses all transaction logs and blocking operations (note that it will wait for active transactions to complete before proceeding)
  • sync_dirty

    : will wait for confirmation that everything will be fine on the remote nodes, but will still remain out of the lock or transaction context.
  • ets

    : basically a way to get around everything Mnesia does and do a series of raw operations on the underlying ETS tables if any. There will be no replication.
+2


source







All Articles