上自动刷新事件NHibernate的表现不佳? [英] NHibernate poor performance on auto flush events?

查看:177
本文介绍了上自动刷新事件NHibernate的表现不佳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说,我知道,NH不建议使用批量操作开始。但作为一个有点兴趣,我想知道这是为什么这么贵。对于我的系统200的物体,它需要4分钟,因为它的时间90 +%的DefaultAutoFlushEventListener.OnAutoFlush(感谢展鹏探查)花费。这是疯狂。我不知道是否有人写了一个自定义的DefaultAutoFlushEventListener围绕这个hinderence为大型重复更新的临时工作。

Let me start by saying that I know that NH doesn't recommend using bulk operations. But as a bit of interest, I was wondering why this is so expensive. For 200 objects in my system, it takes 4 minutes, for which 90+% of the time is spent in DefaultAutoFlushEventListener.OnAutoFlush (Thanks to RedGate Profiler). That's insane. I wonder if anyone has written a custom DefaultAutoFlushEventListener that temporarily works around this hinderence for large repetitive updates.

更新:其实不是批量更新的问题这么多,因为它是与交易和FlushMode进行查询。但尽管如此,到底是什么时候刷新NH干什么?

Update: Actually not an issue with bulk update so much as it is with transactions and FlushMode for queries. But still, what the hell is NH doing when it flushes?

推荐答案

这是一个很好的一个。我曾在一个事务每次更新,而事务中是一个查询,这是2级缓存,但引起了红晕。如果你在一个事务查询,FlushMode =自动(基本上没有关闭),你会得到刷新。这是非常昂贵的,特别是如果你有大量的会话缓存中的对象,这是我们做的。移动此查询出来的交易,由5更进一步的因素增加了查询时间,使整个事情的事务,而不是个人交易是另一大助力,因为每个器transaction.commit导致齐平。更新对象1000的时间不到30秒,我也不好意思说多久那是以前。 。啊遗留代码

This was a good one. I had each update in a transaction, and within that transaction was a query, that was 2nd level cached, but caused a flush. If you have queries in a transaction, and FlushMode=Auto (basically not turned off) you get a flush. Which is extremely expensive, especially if you have lots of objects in session cache, which we do. Moving this query out of the transaction, increased the query time by a factor of 5. Further more, making the whole thing a transaction, instead of individual transactions was a another big boost because each transaction.commit causes a flush. Updating 1000's of objects takes less than 30 seconds, and I'm too embarassed to say how long that was before. Ahh legacy code.

更新:在进一步的调查,我已经设置了FlushMode提交了我们的具体嵌套事务模型。没有考虑太多细节,我们必须使用嵌套的逻辑呼叫时,对于嵌套事务占一个特定的交易模式。对于传统应用程序,我们不想全线设此。在这种情况下,具体的问题是使用事务和设置FlushMode到自动(或总是)的组合

Update: On further investigation, I have set the FlushMode to Commit for our specific nested transaction model. Without going into too much detail, we have a specific transaction model that accounts for nested transactions when using nested 'Logic' calls. For legacy applications we don't want to set this across the board. The specific issue in this case is the combination of using Transactions and setting the FlushMode to Auto (or Always).

这篇关于上自动刷新事件NHibernate的表现不佳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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