免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3207 | 回复: 13
打印 上一主题 下一主题

DB2查询效率问题(详细见内容) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-09-27 10:44 |只看该作者 |倒序浏览
我写java程序通过JDBC查询DB2中的数据库
一共做了1554次循环,在一个循环里查询6次数据库
我每查询一次数据库就把得到的数据用System.out.println()打印出来
结果整个程序执行了大概3个多小时,才全部查询打印完毕
各位大虾看这个速度和效率对吗?
如果有问题,那该怎么提高效率呢?
迫切请求指点啊

论坛徽章:
0
2 [报告]
发表于 2004-09-27 14:07 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2004-09-27 17:43 |只看该作者

DB2查询效率问题(详细见内容)

我想可以考虑:
合理安排I/O;
优化数据库存取;

论坛徽章:
0
4 [报告]
发表于 2004-09-29 13:12 |只看该作者

DB2查询效率问题(详细见内容)

1, check your SQL using the db2 explain
2,create more Index .

论坛徽章:
0
5 [报告]
发表于 2004-09-29 13:44 |只看该作者

DB2查询效率问题(详细见内容)

the performance of your query have to depend on what you did in your java. if you got a lot of checking in java then it will take longer time to process. you may used index advisor to create the index in order to improve the performance but create too many indexes will affect the performance when you performing insert.

论坛徽章:
0
6 [报告]
发表于 2004-09-29 17:22 |只看该作者

DB2查询效率问题(详细见内容)

有5次是做select count(*)
有1次是做select sum(amount)
在for循环里查出一笔就打印一笔

或者可以都查询出来再打印吗?
要求是查询出来的数据也按照在表里的顺序打印出来
有什么好的方法吗?

论坛徽章:
0
7 [报告]
发表于 2004-10-07 11:04 |只看该作者

DB2查询效率问题(详细见内容)

1,For the select count(*)  issue , you can create one index .
1,For the printing  issue  you can creat a temporary table ,insert your data to this table, or creat a txt file . print it after the batch-run.it will impove your batch-run perfermance.

论坛徽章:
0
8 [报告]
发表于 2004-10-07 11:44 |只看该作者

DB2查询效率问题(详细见内容)

actually you can store all the data in an array or write into xml first then only display the result.

论坛徽章:
0
9 [报告]
发表于 2004-10-07 21:31 |只看该作者

DB2查询效率问题(详细见内容)

尽量不要使用count(*),最好是count一个非空字段。另外如果你的表中字段比较多,先把必要的字段导入到一个临时表中,再在临时表中进行查询,效率会提高不少。

论坛徽章:
0
10 [报告]
发表于 2004-10-07 21:57 |只看该作者

DB2查询效率问题(详细见内容)

[quote]原帖由 "足球小子"]尽量不要使用count(*),最好是count一个非空字段。另外如果你的表中字段比较多,先把必要的字段导入到一个临时表中,再在临时表中进行查询,效率会提高不少。[/quote 发表:


May I know why?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP