Tariff Table - Tuple Key Pattern Matching

Inswitch Solutions - Erlang Evaluation <>
Sat Jan 3 01:20:59 CET 2004


Hi,
 
I hope someone can give as some help about this issue. We are trying to
optimize mnesia access time, to phone tariff tables.
This tariff tables, have about 4000 entries each.
 
 The index is a tuple key as follows:
 
{"Tariff_Table_Name","Prefix"}
 
where 
 
Tariff_Table_Name, is the name of the Tariff plan that applies to the
subscriber
 
And
 
Prefix, is a string, the first digits of the called number. 
 
So our queries are (Tariff Table Name="TARIFF"):
 
MatchHead = #tarifftable{tarifftablekey='$1', _='_'},
 Guard = [{'==',{element,1,'$1'}, "TARIFF"}],
 Result = '$1',
 Select = fun() ->
               mnesia:select(tarifftable,[{MatchHead, Guard, [Result]}])
           end,

 {atomic, Res} = mnesia:transaction(Select),
 Res.
 
So, as a result, it brings 4000 tuples, of the form
"{"Tariff_Table_Name","Prefix"}
 
Later the application searches for the "prefix" that better martches the
called number (the prefix is a substring of the called number). My
question is, instead of bringing all 4000 tuples, can I bring just the
most similar "Prefix", like the one which have an specific first
caracter? So instead of bringing 4000 tuples, I may bring just the most
similar ones (the prefixes which are more similar to the destination
number?)
 
Best Regards,
 
daniel
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040102/69f418ce/attachment.html>


More information about the erlang-questions mailing list