Skip to content
/ frags Public

Tutorial on how to do mnesia table fragmentation

Notifications You must be signed in to change notification settings

drozzy/frags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Mnesia Table Fragmentation

How to start

Launch erl shell with mnesia:

erl -mnesia

Compile:

c(frags).

Create the tables and schema:

frags:create().

Start the observer, and inspect the "Table Viewer -> View/Mnesia Tables" menu:

observer:start().

You should see two frags. Try adding some sample data:

frags:populate(100).    

Now those tables shold have more data. Now add and remove some frags and examine the tables:

frags:add_frag().
frags:add_frag().
frags:del_frag().

Now delete all the frags by repeated issuing del_frag:

frags:del_frag().
...

Make sure only one table remains. Then disable the fragmentation for this table:

frags:deactivate().

At this point it becomes a regular table. We are no longer able to add fragments. Try this (what happends?):

frags:add_frag().

Take NOTE that adding data with populate will not always work now. This is because it still hashes (to frags) that don't exist. Use populate_no_frag to add data (which uses just vanilla transactions):

frags:populate_no_frag(100).

Now reactivate the fragmentation:

frags:activate().

And we can add frags again:

frags:add_frag().

References

Following these two resources:

About

Tutorial on how to do mnesia table fragmentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages