Danil Onishchenko
Danil Onishchenko

Reputation: 2040

How to effectively delete a lot of mnesia tables

I faced a situation when I need to delete a lot of mnesia tables on the node (about 20000). Since there is a name pattern for these tables I can collect and delete them this way:

Tables = [Table || Table <- mnesia:system_info(tables), re:run(atom_to_list(Table), "<pattern>") /= nomatch],
lists:foreach(
    fun (Table) ->
        mnesia:delete_table(Table)
    end,
    Tables).

However deleting them one by one is very slow and it takes very long to delete 20k tables. Is there any way to do it more effectively?

Upvotes: 2

Views: 184

Answers (1)

Hitesh Vaghani
Hitesh Vaghani

Reputation: 1362

you can spawn processes.

lists:foreach(
    fun (Table) ->
        spawn(mnesia, delete_table, [Table])
    end,
    Tables).

Upvotes: 1

Related Questions