Managing incremental counters in mnesia DBMS?

徘徊边缘 提交于 2019-12-03 17:32:53

Is a counter the best solution for your problem? I expect that a highly distributed system is probably better off not having them and hence they have been left out.

  1. If you want a count of how many elements are in the table. Have a separate table of record {counts, TableName, Count} and use the dirty_update_counter operation in the add and remove transactions of your storage tables.
  2. If you want to retrieve data in a specific order (the order they were added for instance) look at using an OrderedBy solution shown here.
  3. If you want fast foreign key lookups, I would look at playing around with the type of your keys (binary values for item_id maybe faster) and test if you get any significant improvement.

Also, I don't understand why you have to update the counter on every record when a table entry is deleted. I didn't think MySQL or any other RDBMS did this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!