mnesia:match_object() on an ordered_set

Ulf Wiger etxuwig@REDACTED
Thu Apr 24 16:14:40 CEST 2003


I started writing some code happily assuming that calling
mnesia:match_object/2 on an ordered_set table will return
an ordered set of objects. For a brief moment, some doubt
snuck in and I decided to check the actual implementation...

It turns out, AFAICT, that mnesia simply prepends objects
written during the transaction, thus breaking the
ordered_set semantics, and -- In my opinion -- violating the
Principle of Least Surprise(tm).

The Mnesia documentation doesn't make any promises regarding
order, so this behaviour doesn't formally violate the Mnesia
interface. However, where anything is written about the
expected semantics of match_object(), the following can be
found in the ETS Reference Manual:

"On tables of the ordered_set type, the result is in the
same order as in a first/next traversal."

Given the current implementation of mnesia:match_object(), I
don't think preserving the order would have to impact
performance, esp. not on large sets (and on small sets, I
don't think it matters.)

I've not made a patch. I could suggest a fix, but not today.

/Uffe
-- 
Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson AB, Connectivity and Control Nodes




More information about the erlang-questions mailing list