Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Mnesia disc_copies table stored in ram when application starts?

I have a table A of type disc_copies. It has two files on the disk.

  1. A.DCD - last modified time 30th Aug
  2. A.DCL - today(7th Sep)

As per my understanding, A.DCL is log file and A.DCD has all the data. Today I have done multiple operations on A, however A.DCD remains same but size of A.DCL was increased. When my application starts how this table gets stored in ram when DCD file is not changed. Proper Documentation is not available, so can anyone tell what is the exact process ? Also DCD file gets very large over the time even though there is no data in the table, can anyone clarify ?

like image 905
akagrawal Avatar asked Mar 03 '23 02:03

akagrawal


1 Answers

For a disc_copies table, the data is read into an ETS table when Mnesia starts, so the whole table exists in RAM. The DCD is the latest full snapshot, and the DCL file contains the changes made after the snapshot, so first the DCD is loaded and then the DCL entries are applied. As you perform operations on the table, entries are appended to the DCL. When the DCL grows large enough, Mnesia makes a new full DCD dump and empties the DCL.

Since all data is in RAM at runtime, things like full table searches are very fast, but you can end up needing a whole lot of RAM, and the startup times can get quite long.

like image 200
RichardC Avatar answered Mar 05 '23 17:03

RichardC