12
返回列表 发新帖
楼主: oracle杀手

[性能调整] group by 导致性能下降

[复制链接]
论坛徽章:
0
11#
 楼主| 发表于 2021-10-11 09:45 | 只看该作者
ZALBB 发表于 2021-10-10 20:24
做个GATHER_PLAN_STATISTICS,就知道时间消耗在哪,此时再有针对性的优化,就立竿见影了,

其实就是消耗在group by上了,拆分运行和不加group by运行都很快的

使用道具 举报

回复
论坛徽章:
0
12#
发表于 2021-10-11 10:38 | 只看该作者
按照楼主描述的现象 应该是pga过小 临时表排序慢
楼主可以提供一下 没有group by 的执行计划看看

使用道具 举报

回复
论坛徽章:
2
20周年集字徽章-周
日期:2023-08-03 16:37:4519周年集字徽章-19
日期:2024-09-07 21:32:18
13#
发表于 2021-10-12 20:34 | 只看该作者
oracle杀手 发表于 2021-10-11 09:40
not in这个语句我单独运行过,很快,把这个整个语句拆分运行,都没有问题,只要不加group by 30秒内也会 出 ...

not in里面的语句单独执行和整个语句拆分执行, 对优化分析没有多大意义. 不加group by的30秒出结果, 从出第一条结果到出完结果的整个时间是多少?  filter 执行计划相当于nested loop, 很快出结果很正常, 但是整个结果都出完的时间应该比group by 要长.   这种sql , 收集一个sqlhc, 就知道原因和解决方法了. 知道分析sql需要哪些信息, 很重要.

使用道具 举报

回复
论坛徽章:
314
行业板块每日发贴之星
日期:2012-07-12 18:47:29双黄蛋
日期:2011-08-12 17:31:04咸鸭蛋
日期:2011-08-18 15:13:51迷宫蛋
日期:2011-08-18 16:58:25紫蛋头
日期:2011-08-31 10:57:28ITPUB十周年纪念徽章
日期:2011-09-27 16:30:47蜘蛛蛋
日期:2011-10-20 15:51:25迷宫蛋
日期:2011-10-29 11:12:59ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41鲜花蛋
日期:2011-11-09 20:33:30
14#
发表于 2021-10-13 08:57 | 只看该作者
sql_tigerliu 发表于 2021-10-12 20:34
not in里面的语句单独执行和整个语句拆分执行, 对优化分析没有多大意义. 不加group by的30秒出结果, 从出第 ...

收集SQL的SQLHC,能看到什么?

使用道具 举报

回复
论坛徽章:
78
ITPUB15周年纪念
日期:2020-08-28 17:23:53双鱼座
日期:2016-03-19 19:38:31秀才
日期:2016-02-18 09:31:52秀才
日期:2016-01-25 15:02:04双子座
日期:2016-01-19 20:35:54秀才
日期:2016-01-13 12:14:26秀才
日期:2015-12-25 15:31:10秀才
日期:2015-12-18 09:28:57秀才
日期:2015-12-14 14:56:09秀才
日期:2015-12-14 14:51:16
15#
发表于 2021-10-14 10:11 | 只看该作者
这种执行计划显示是不准确的,最好给sql monitor active report。看看到到底走了什么执行计划。

使用道具 举报

回复
论坛徽章:
0
16#
发表于 2021-10-25 00:40 来自手机 | 只看该作者
Let’s make sure the following facts.  First, the logical process is to return the daily trade volumes for all small orgs.  Second, all shops belong to small orgs can not be more than 150,000 (total shops), say about half at time being.  The problem is definitely the not in clause due to data modeling.  Assume adding orchid in his table, which probably solves the critical part by directly joining bbb table using index on .orgid/top orgid.  Without changing data model, you do want parallel hash join.  But no surprise Oracle optimizer gets lost in every step.  Why it chooses global index while group by is on partition column trade date?  Why it uses nested join on first table aaa and then hopelessly using index on joining bbb table?  Now come back to solutions.  The natural parallel execution needs his table to be the leading table with each spread on one partition and return the sum volume independently.  But hash join wants to build hash table on small data set and then loop his partitions one by one.  So it appears a conflict here.  If Oracle optimizer is smart enough it should allow to create a materialized view from aaa joining bbb first and then build a leading hash table and then all parallel hash join by loop each his partition one by one.  It would be great if working in that way.  If not, try other options such as materialized view or global temp table with index.  But for personal interest, I would test that creating a joined materialized view for aaa an bbb with order by in with clause (hope it creates an indexing function), or use table function to return a associate array to serve as a indexed table.  Certainly there is a lot to learn during this optimization course.

使用道具 举报

回复
论坛徽章:
5
2014年新春福章
日期:2014-02-18 16:50:09马上有车
日期:2014-02-18 16:50:09优秀写手
日期:2014-10-21 06:00:13秀才
日期:2017-08-18 11:04:35弗兰奇
日期:2020-05-19 13:26:49
17#
发表于 2022-10-24 15:39 | 只看该作者
oracle杀手 发表于 2021-10-9 09:15
感觉上应该不能是索引的问题吧,而且这个上面是有索引的,你看下filter4,这个表的字段返回值还是很多的大 ...

哈哈 , 一年没登录了。 我就想知道,加上索引,快没快。。。。。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表