哪个ORM框架可以最好地处理MVCC数据库设计? [英] Which ORM framework can best handle an MVCC database design?

查看:285
本文介绍了哪个ORM框架可以最好地处理MVCC数据库设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计数据库以使用MVCC(多版本并发控制)时,您创建具有类似IsLatest或整数VersionId的布尔字段的表,并且您从不进行任何更新,事情会改变的。



MVCC允许您对需要详细历史记录的应用程序进行自动审计,并且还可以减轻数据库对更新锁定的压力。缺点是,它使您的数据大小更大,并减慢选择,由于额外的子句获得最新版本。

(请注意,我不是讨论RDBMS中的本机MVCC支持,如SQL Server的快照隔离level)



这已经在Stack Overflow的其他文章中讨论过了。 [todo - links]



我想知道,哪些流行的实体/ ORM框架(Linq to Sql,ADO.NET EF,Hibernate等)设计类型?这是典型的ActiveRecord设计模式的一个重大变化,所以我不知道是否大多数工具可以帮助一个人决定走这条路线与他们的数据模型。我特别感兴趣的是如何处理外键,因为我甚至不确定最好的数据模型来支持MVCC。

解决方案

我可能考虑在数据库中实现MVCC层,使用存储的procs和视图来处理我的数据操作。然后,您可以向任何能够映射到和来自存储过程的ORM呈现一个合理的API,并且您可以让DB处理数据完整性问题(因为它几乎是构建的)。如果你这样做,你可能想看看一个更纯粹的Mapping解决方案,如IBatis或IBatis.net。


When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with either a boolean field like "IsLatest" or an integer "VersionId", and you never do any updates, you only insert new records when things change.

MVCC gives you automatic auditing for applications that require a detailed history, and it also relieves pressure on the database with regards to update locks. The cons are that it makes your data size much bigger and slows down selects, due to the extra clause necessary to get the latest version. It also makes foreign keys more complicated.

(Note that I'm not talking about the native MVCC support in RDBMSs like SQL Server's snapshot isolation level)

This has been discussed in other posts here on Stack Overflow. [todo - links]

I am wondering, which of the prevalent entity/ORM frameworks (Linq to Sql, ADO.NET EF, Hibernate, etc) can cleanly support this type of design? This is a major change to the typical ActiveRecord design pattern, so I'm not sure if the majority of tools that are out there could help someone who decides to go this route with their data model. I'm particularly interested in how foreign keys would be handled, because I'm not even sure of the best way to data model them to support MVCC.

解决方案

I might consider implementing the MVCC tier purely in the DB, using stored procs and views to handle my data operations. Then you could present a reasonable API to any ORM that was capable of mapping to and from stored procs, and you could let the DB deal with the data integrity issues (since it's pretty much build for that). If you went this way, you might want to look at a more pure Mapping solution like IBatis or IBatis.net.

这篇关于哪个ORM框架可以最好地处理MVCC数据库设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆