[erlang-questions] ets select match specification analysis

Tom McNulty <>
Sat Jul 25 22:37:06 CEST 2009


>
> Paul Mineiro wrote:
>> currently tcerl will also recognize a partially bound prefix key and
>> restrict the range of keys considered.  however for an application  
>> i'm
>> working on i need efficient queries corresponding to match  
>> specifications
>> that look like
>> [ { { { '$1', '_' }, '_' },
>>    [ { '>', '$1', Lower }, { '<', '$1', Upper } ],
>>    [ '$_' ]
>>  }
>> ]
>> which ideally would only consider the range of keys defined by tuples
>> whose first element is between Lower and Upper.
>
> Ideally, yes, but the way select() is implemented, it will still
> result in a full scan of the table, unless I've missed some
> key release note somewhere. I'd love to be proven wrong.

Should be able to avoid a full scan with ordered_set's

Efficiency guide:
"There are exceptions when the complete table is not scanned, for  
instance if part of the key is bound when searching an ordered_set  
table, or if it is a Mnesia table and there is a secondary index on  
the field that is selected/matched. If the key is fully bound there  
will, of course, be no point in doing a select/match, unless you have  
a bag table and you are only interested in a sub-set of the elements  
with the specific key."

- Tom


>
> BR,
> Ulf W
> -- 
> Ulf Wiger
> CTO, Erlang Training & Consulting Ltd
> http://www.erlang-consulting.com
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>



More information about the erlang-questions mailing list