insert a record

Hakan Mattsson <>
Mon May 23 10:22:17 CEST 2005


On Wed, 18 May 2005, Ulf Wiger (AL/EAB) wrote:

Uffe> The index is transparent to insert operations.
Uffe> Mnesia maintains the indexes behind the scenes, and you
Uffe> never have to specify indexes except (a) when you create
Uffe> the table and (b) when you specifically want to use the 
Uffe> index to locate data in your table.

This is true, but in order to avoid mis-understandings it
may be worth to point out that (b) is not needed when using
Mnesia's functions for match_object and select.

...

Dietmar> What I have is :
Dietmar> 
Dietmar>  mnesia:create_table(centerDisplayProcessesList, [{snmp, 
Dietmar> [{key, integer}]},
Dietmar>                               {attributes, record_info(fields, 
Dietmar> centerDisplayProcessesList)},
Dietmar>                               {disc_copies, Nodes}]) of
Dietmar> 
Dietmar> So I have a integer (snmp) index.
Dietmar> 
Dietmar> Now I would be able to just insert a new record for which I 
Dietmar> do not care about the index.

Nowdays, when tables in Mnesia may be ordered, you do not
need to use a separate SNMP index in Mnesia. A more efficient
approach is to select the table keys so the main table
automatically gets sorted according to the SNMP rules.

In your case when the key is a plain integer the separate
SNMP index is totally superfluous.

/Håkan


More information about the erlang-questions mailing list