Mnesia: When querying an ordered_set table, are the records returned in a guaranteed order?

StackOverflow https://stackoverflow.com/questions/13004414

  •  13-07-2021
  •  | 
  •  

Domanda

Will selects and reads (along with their dirty_ cousins) return records in sort-order of the primary key when the table is of *ordered_set*? In other words if my select matches more than one record is any guarantee made about the order of the records returned? Similarly, if an index_read is used and pulls more than one record back, are they sorted in any specific way with respect to the primary key

È stato utile?

Soluzione

Short answer: Yes. If you are using an ordered_set and match multiple objects, they will be ordered when returned.

mnesia is largely built around ets and the documentation will direct you to the ERTS user's guide and ets user's guide for implementation details.

From the ets user's guide on select:

On tables of the ordered_set type, objects are visited in the same order as in a first/next traversal. This means that the match specification will be executed against objects with keys in the first/next order and the corresponding result list will be in the order of that execution.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top