mnesia_frag ????

Sanjaya Vitharana sanjaya@REDACTED
Tue Jan 17 06:17:35 CET 2006


HI .... /Uffe & bengt

Many thanks for your quick replies.

"...But I would strongly recommend against using
dirty access in combination with fragmented tables."

"Both read and write in fragmented tables are complex operations."

If we use the original function without dirty, how it will effect to the
efficiency of the huge table something like ~3G (3M rec x 1K).

Also, how the number of fragments will effect to the table access?? since
the operetions are complex (as you told), can the number of fragments
degrade the performance (depending upon the numberof record / table size)? I
mean the record access time against the number of fragments (I assume the
number of records in the table as constant).

And also refereing to the
http://www.erlang.org/ml-archive/erlang-questions/200307/msg00052.html.ORIG
if we change the access_module configuration parameter to mnesia_frag it
says "> without doing any changes to your old code." So ... going back to
the problem I faced with mnesia:dirty_read(Db, DBKey), the first thing come
to my mind is,  <<changes to the access_module configuration parameter is
applicable or NOT>>

Refering to my original question I have used the {disc_copies, NodeList} ,
so why the mnesia:info() shows only the schema table as disc_copies???


Thanks in advance

Sanjaya Vitharana



----- Original Message -----
From: "Ulf Wiger (AL/EAB)" <ulf.wiger@REDACTED>
To: "Rikard Johansson" <rikard.johansson@REDACTED>
Cc: "Sanjaya Vitharana" <sanjaya@REDACTED>; <erlang-questions@REDACTED>
Sent: Monday, 16 January 2006 08:03 pm
Subject: RE: mnesia_frag ????



...But I would strongly recommend against using
dirty access in combination with fragmented tables.
The thing about dirty access is that it's only
at best semi-safe when multiple table copies are
involved. Both read and write in fragmented tables
are complex operations. While dirty will work most
of the time, it can give you some really nasty
surprises...

/Uffe

> -----Original Message-----
> From: Rikard Johansson [mailto:rikard.johansson@REDACTED]
> Sent: den 16 januari 2006 14:02
> To: Ulf Wiger (AL/EAB)
> Cc: Sanjaya Vitharana; erlang-questions@REDACTED
> Subject: Re: mnesia_frag ????
>
>
>
> As Ulf says, you should use mnesia:read within the ReadFun,
>
> ReadFun = fun(Db,DBKey) ->  mnesia:read({Db, DBKey}) end.
>
> However, if you want "dirty access" you can use the 'sync_dirty'
> AccessContext.
>
> mnesia:activity(sync_dirty, ReadFun, [profile_db,777], mnesia_frag).
>
> /Rikard
>
> Ulf Wiger (AL/EAB) wrote:
> >
> > Don't use mnesia:dirty_read/2 as your read function.
> > Try with mnesia:read({Tab, Key}) instead.
> >
> > Dirty_read() goes directly to the (base-) table, and has no
> concept of
> > mnesia_frag.
> >
> > /Uffe
> >
> >
> --------------------------------------------------------------
> ----------
> >     *From:* owner-erlang-questions@REDACTED
> >     [mailto:owner-erlang-questions@REDACTED] *On Behalf
> Of *Sanjaya
> >     Vitharana
> >     *Sent:* den 16 januari 2006 13:32
> >     *To:* erlang-questions@REDACTED
> >     *Subject:* mnesia_frag ????
> >
> >     Hi .. !!!
> >
> >     Can any one show me where I'm doing wrong, I'm trying to write a
> >     single record & retrive it using mnesia_frag.
> >
> >     But it's not working :( for me.
> >
> >     (vmdb@REDACTED)29 <mailto:vmdb@REDACTED)29>>
> >     mnesia:table_info(profile_db, frag_properties).
> >     [{base_table,profile_db},
> >      {foreign_key,undefined},
> >      {hash_module,mnesia_frag_hash},
> >      {hash_state,{hash_state,30,15,4}},
> >      {n_fragments,30},
> >      {node_pool,[vmdb@REDACTED]}]
> >     (vmdb@REDACTED)31 <mailto:vmdb@REDACTED)31>> WriteFun1
> = fun(DbFile,
> >     Rec) -> mnesia:write(DbFile, Rec, write)end.
> >     #Fun<erl_eval.12.2225172>
> >     (vmdb@REDACTED)32 <mailto:vmdb@REDACTED)32>>
> >     mnesia:activity(transaction, WriteFun1, [profile_db,
> >     {profile_db,777,"test",333,1234,5678,1234}], mnesia_frag).
> >     ok  --- Here it shows as it works
> >     (vmdb@REDACTED)33 <mailto:vmdb@REDACTED)33>> ReadFun =
> fun(Db,DBKey)
> >     ->  mnesia:dirty_read(Db, DBKey)end.
> >     #Fun<erl_eval.12.2225172>
> >     (vmdb@REDACTED)34 <mailto:vmdb@REDACTED)34>>
> >     mnesia:activity(transaction, ReadFun, [profile_db,777],
> mnesia_frag).
> >     [] -- but empty list given when try to retrive
> >     (vmdb@REDACTED)35 <mailto:vmdb@REDACTED)35>>
> >     mnesia:dirty_first(profile_db).
> >     '$end_of_table'  --- since the db should contains only
> 2 records, I
> >     tried this. but :(
> >     (vmdb@REDACTED)36 <mailto:vmdb@REDACTED)36>>
> >
> >
> >     Furthermore I have used below, to create the DB.
> >
> >     -record(profile_db, {mobile_no, prof_details, type,
> >     last_update_date, first_creation_date, fax_no}).
> >
> >        Res = mnesia:create_table(profile_db,[
> >                           {disc_copies, NodeList},
> >                           {type, ordered_set},
> >                           {index, [type, last_update_date,
> >     first_creation_date, fax_no]},
> >                           {frag_properties, [{n_fragments, 30}]},
> >                           {attributes, record_info(fields,
> profile_db)}
> >                           ]),
> >
> >
> --------------------------------------------------------------
> --------------------------------------------------------------
> ------------------------
> >     consider the mnesia:info() result below, and note that the
> >     profile_db_frag2: with 1        records occupying 95
>    words of mem
> >     disc_copies        = [schema]
> >     but I have used  {disc_copies, NodeList}
> >
> >
> ----------------------------------------------------------------------
> >
> ----------------------------------------------------------------------
> > --------
> >
> >     (vmdb@REDACTED)43 <mailto:vmdb@REDACTED)43>>
> >     mnesia:info().
> >     ---> Processes holding locks <---
> >     ---> Processes waiting for locks <---
> >     ---> Participant transactions <---
> >     ---> Coordinator transactions <---
> >     ---> Uncertain transactions <---
> >     ---> Active tables <---
> >     profile_db     : with 0        records occupying 70
>   words of mem
> >     profile_db_frag2: with 1        records occupying 95
>    words of mem
> >     ......
> >     profile_db_frag13: with 1        records occupying 95
>     words of mem
> >     .......
> >     profile_db_frag29: with 0        records occupying 70
>     words of mem
> >     profile_db_frag30: with 0        records occupying 70
>     words of mem
> >     schema         : with 31       records occupying 4380
>   words of mem
> >     ===> System info in version "4.2.3", debug level = none <===
> >     opt_disc. Directory "/usr2/omni_vm_prof/db/vmdb" is used.
> >     use fallback at restart = false
> >     running db nodes   = [vmdb@REDACTED]
> >     stopped db nodes   = []
> >     master node tables = []
> >     remote             = []
> >     ram_copies         = [profile_db,
> >                           profile_db_frag10,
> >                           profile_db_frag11,
> >
> >                           ...
> >
> >                           profile_db_frag8,
> >                           profile_db_frag9]
> >     disc_copies        = [schema]
> >     disc_only_copies   = []
> >     [{vmdb@REDACTED,disc_copies}] = [schema]
> >     [{vmdb@REDACTED,ram_copies}] = [profile_db_frag30,
> >                                     profile_db_frag29,
> >
> >                                     .....
> >
> >                                     profile_db_frag3,
> >                                     profile_db_frag2,
> >                                     profile_db]
> >     12 transactions committed, 5 aborted, 0 restarted, 0
> logged to disc
> >     0 held locks, 0 in queue; 0 local transactions, 0 remote
> >     0 transactions waits for other nodes: []
> >     ok
> >     (vmdb@REDACTED)44 <mailto:vmdb@REDACTED)44>>
> >
> >
> >     I have confused with the results, can anyone explane this ??
> >
> >     Thanks in advance.
> >
> >     Sanjaya Vitharana
>
>




More information about the erlang-questions mailing list