Frage

I want to fetch records from mnesia by inserted order.

At first, I want to add a timestamp column. But it is found for a group of nodes of different computers, the timestamp is created by different computers. It can't be guaranteed that these different computer's timer is synchronized.

That, I think it can be solved by database's transaction in mnesia for generating sequential value. But it may be too costly.

I wonder that the mnesia(qlc)'s output record's order is guaranteed for insert order. If so, the above trouble won't exist.

War es hilfreich?

Lösung

Mnesia uses hash tables internally by default, so there is no specific order you can rely on. In general, this problem is not solvable without some kind of consensus between the systems. Say a global counter or something such.

A better way is to think if you really need to order everything that strictly. Often you don't and only want a weaker ordering as in "This definitely happened before, but this is roughly at the same time, so let us just pick some order between them."

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top