最近接触到政府的人社系统,用户数据都有上千万,对于查询慢,有的地方上反映就连删除一条数据都要好几分钟,系统开发用的是SSH框架,系统慢主要是在数据库上,数据库用的是oracle11g,反映到系统反应慢不知道是不是跟框架有问题,网上也搜了下,也又说Hibernate不适合的,那我想问哈最好用什么呢?或则是给出点具体的Hibernate的缺陷!!
------解决思路----------------------
数据了很大的系统 一般都是自己写sql 这样才能保证效率最优
至于hibernate支撑千万级别的应该还是可以做到
只不过要求对hibernate掌握比较精通
才能用最优的配置去做,节省很多性能
hibernate的强处在于把复杂的表关系映射成了对象
这样处理表关系很简单
但是如果配置不当会导致性能低下
还有 hibernate对于大批量的更新与删除这类效率是会低一些 算是弱点
但是也不至于到删除一条记录要几分钟的情况
你们这个系统慢,感觉锅不能全分给hibernate
··估计是很多方面原因引起的···
得具体问题具体分析了··
------解决思路----------------------
说hibernate不适合的大概对hibernate一知半解。hibernate创始人Gavin King,同时也是EJB3的主要负责人。javaee标准制订者之一,可用性你应该可以相信。至于说效率不高的,一般都是使用不好,很多时候有些人为了开发不报错,把lazy配置成false导致不必要的数据查询和加载。这样的例子太多了。hibernate如果有有开销,无非是把hql或者critira翻译为sql这一点。但你也应该知道,瓶颈完全不是这里。合理使用hibernate,绝对不会导致比jdbc有什么大的性能差异,除非用的真的够差。
------解决思路----------------------
五楼说的对 关闭了延迟加载 比如你查询一个实体 此实体一对多关联n个实体 会发出多条查询语句,效率极低 插入,修改,删除等地方可以使用Sqlquery 批量操作
------解决思路----------------------
is there some benchmark to support u? "合理使用hibernate,绝对不会导致比jdbc有什么大的性能差异".
I am not even a java developer, so correct me if any statement I make here doesn't make sense to u java gurus...
imho, hibernate was not invented for improving application performance in production environment due to the fact that whatever hibernate magic does, it still goes through jdbc so it can be considered as a tier on top of jdbc. How come you add one more layer without suffering any performance loss? of course, hibernate shall prove it offers fairly good performance against most rdbms in all common scenarios...
here is the definition of hibernate on wiki:
"Hibernate ORM enables developers to more easily write applications whose data outlives the application process. As an Object/Relational Mapping (ORM) framework, Hibernate is concerned with data persistence as it applies to relational databases (via JDBC)."
I guess hibernate was designed for freeing developers from rdbms implementation so they could focus on business logic.
for this particular argument, I think it's not fair. It's too early to blame on hibernate without any in depth analysis to track down the bottleneck. any performance tunning should be based upon fact not suspicion...
just my 2 cents!