Hibernate:动态更新动态插入 - 性能效果 [英] Hibernate : dynamic-update dynamic-insert - Performance Effects

查看:18
本文介绍了Hibernate:动态更新动态插入 - 性能效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 dynamic-update 或 dynamic-insert 有积极作用,但通常只对性能影响很小,正如 http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/

Using dynamic-update or dynamic-insert has positive, though generally slight only on performance, as also mentioned by http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/

但是参考文档提到这可能会产生负面的性能影响,如下面的 http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-class:

But the reference documentation mentions that this could have negative performance effects also as mentioned below in http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-class :

虽然这些设置可以增加在某些情况下,他们可以实际上降低了性能其他.

Although these settings can increase performance in some cases, they can actually decrease performance in others.

有人可以建议一些示例/场景,提及相同的负面性能影响吗?

Can anybody please suggest some example/scenario mentioning negative performance impact of the same?

推荐答案

Hibernate 缓存 每个 实体的实际 INSERT/SELECT/UPDATE SQL 字符串,明显的好处是它不必当您想要持久化、查找或更新实体时计算 SQL.

Hibernate caches the actual INSERT/SELECT/UPDATE SQL strings for each entity and the obvious benefit is that it doesn't have to compute the SQL when you want to persist, find or update an entity.

但是,在使用动态插入或动态更新时,Hibernate 每次都必须生成相应的 SQL 字符串,因此在 Hibernate 方面存在性能成本.

However, when using dynamic-insert or dynamic-update, Hibernate has to generate the corresponding SQL string each time and there is thus a performance cost on the Hibernate side.

换句话说,在数据库端和 Hibernate 端的开销之间存在权衡.

In other words, there is a trade-off between overhead on the database side and on the Hibernate side.

我的观点是动态插入和动态更新对于具有胖 blob 列的表或具有大量列的表可能很有趣.在其他情况下,我不相信动态插入或更新总是意味着性能提升(默认情况下我不使用它们).但与往常一样,您应该衡量它.

My point of view is that dynamic insert and dynamic update can be interesting for tables with a fat blob column or tables with a huge number of columns. In other cases, I'm not convinced that dynamic insert or update always means performance boost (I do not use them by default). But as always, you should measure it.

  • Re: Request for dynamic update-SQL for some feedback from the Hibernate developers

这篇关于Hibernate:动态更新动态插入 - 性能效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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