简体   繁体   English

休眠查询比MySQL中的本地查询慢

[英]Hibernate queries slow than native queries in MySQL

I am working on a project which involves MySQL database which has billions of rows and building a Java based application on top of it. 我正在从事一个涉及MySQL数据库的项目,该数据库具有数十亿行,并在其之上构建基于Java的应用程序。 I am using Hibernate as ORM. 我正在使用Hibernate作为ORM。 While I execute a complex query on MySQL it is taking about 2.5 secs to execute where as in Hibernate the same query is taking about 8.9 secs. 当我在MySQL上执行复杂的查询时,与在Hibernate中执行相同的查询大约需要8.9秒的时间来执行大约2.5秒。 Are there any settings I need to change to reduce the execution time in Hibernate? 我需要更改任何设置以减少Hibernate中的执行时间吗?

Hibernate is a bit slower than native - that's to be expected... Have you defined the indexes properly? Hibernate比本机慢一些-可以预料到...您是否正确定义了索引? Are you using lazy loading (you should be). 您是否正在使用延迟加载(应该)。 What query is hibernate spitting out to fetch your data compared to the native (use hibernate.show_sql=true) 与本地相比,什么查询是休眠的,会吐出以获取您的数据(使用hibernate.show_sql = true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM