我使用SSH 在持久层进行查询,使用的是HibernteaTemplate().findByCriteria(DetachedCriteria.forClass(User.class))
进行查询 其中User.class是我在action里面传过来的 ,现在的问题是 我的User表中只有100多条信息 12列 每次打开网页查询的时间居然要15-30秒 才能打开页面数据,实在不太明白,所以来这里问问。希望能找到答案。
Hibernate 查询数据时,速度慢的异常。请大家帮忙看看。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
9条回答 默认 最新
- oxcow 2012-01-04 16:03关注
根据你提供的日志,这是你一次查询执行的所有SQL[code="SQL"]SELECT * FROM mastery.sale_pricing_record this_;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.doc_port docport0_ WHERE docport0_.id = ?;
SELECT * FROM mastery.doc_port docport0_ WHERE docport0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.doc_port docport0_ WHERE docport0_.id = ?;
SELECT * FROM mastery.doc_port docport0_ WHERE docport0_.id = ?;
SELECT * FROM mastery.sale_customer this_;
SELECT * FROM mastery.doc_port this_;
SELECT * FROM mastery.doc_aircompany this_;
SELECT * FROM mastery.doc_shipcompany this_;[/code]其中我省略了你的表字段。
我们可以看下[code="sql"]SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;
SELECT * FROM mastery.sale_customer salecustom0_ WHERE salecustom0_.id = ?;[/code]
这个应该是你设置了一对多,但没有设置抓取数量导致的,针对一个id都需要一条sql,所以你需要设置下BatchSize。其他的就不说了。类似吧。注意个大小要合适,不能太大,因为其实他是吧上述四条SQL变成 id in (?,?,?...)的方式。至于你的意外发现,我没怎么遇到过,不过你的log4j也挺复杂的。你可以只把写文件关了,看是不是由写文件导致的。在一个就是吧不需要的打印的信息去掉,指保留SQL的。这是我的ssh项目log4j给你参考下,很简单的[quote]
log4j.rootLogger=info, stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %m [%l]%n#下面是为了查看hibernate映射,设置为debug。想要生效,
#只需要吧第一行的info改成debug就行
log4j.appender.org.springframework.orm.hibernate3 = debug
[/quote]对于log4j就只能提供这么多。你可以在自己搜搜。或者对你的log4j进行下测试。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog