原生SQL(使用MySQL)与使用Hibernate ORM的性能差异? [英] Performance difference of Native SQL(using MySQL) vs using Hibernate ORM?

查看:157
本文介绍了原生SQL(使用MySQL)与使用Hibernate ORM的性能差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Spring MVC用于涉及多级后端管理和客户/成员前端的应用程序.该项目最初是在没有框架的情况下启动的,并且没有用于数据库访问的简单本机JDBC调用.

I am using Spring MVC for an application that involved a multilevel back end for management and a customer/member front end. The project was initially started with no framework and simple native JDBC calls for database access.

随着项目的迅速发展(就像往常一样),我进行了更重要的数据库调用,有时查询的选择量很大.

As the project has grown significantly(as they always do) I have made more significant database calls, sometimes querying large selection sizes.

我正在尽我所能来处理我的数据库调用,以紧密模拟对象关系映射最佳实践,但是仍在使用JDBC.我一直在考虑是否应该过渡到休眠状态,但是不确定是否值得.如果值得获得性能提升,我将愿意这样做.

I am doing what I can to treat my db calls to closely emulate Object Relational Mapping best practices, but am still just using JDBC. I have been contemplating on whether or not I should make the transition to hibernate, but was unsure if it would be worth it. I would be willing to do it, if it was worth a performance gain.

使用JDBC在本地SQL上使用Hibernate(甚至只是对象关系映射)是否会提高性能?

Is there any performance gain from using Hibernate( or even just Object Relational Mapping) over native SQL using JDBC?

推荐答案

使用JDBC在本机SQL上使用Hibernate(甚至只是对象关系映射)是否会提高性能?

Is there any performance gain from using Hibernate (or even just Object Relational Mapping) over native SQL using JDBC?

使用ORM,数据映射器等不会使相同的SQL查询运行得更快.但是,使用Hibernate时,您可以受益于诸如惰性加载二级缓存查询缓存之类的功能,这些功能可能有助于改善性能. .我并不是说Hibernate对于每个用例都是完美的(对于特殊情况,Hibernate无法很好地处理,您总是可以退回到本机SQL),但是它做得非常不错,并且肯定会缩短开发时间(即使在增加时间之后)用于优化).

Using an ORM, a datamapper, etc won't make the same SQL queries run faster. However, when using Hibernate you can benefit from things like lazy loading, second level caching, query caching and these features might help to improve the performances. I'm not saying Hibernate is perfect for every use case (for the special cases Hibernate can't handle well, you can always fall back to native SQL) but it does a very decent job and definitely improves development time (even after adding time spent on optimization).

但是说服自己的最好方法是衡量事物,根据您的情况,我可能会创建一个涵盖某些代表性场景的Hibernate原型并将其进行试验.

But the best way to convince yourself would be to measure things and in your case, I would probably create an Hibernate prototype covering some representative scenarios and bench it.

这篇关于原生SQL(使用MySQL)与使用Hibernate ORM的性能差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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