12
返回列表 发新帖
楼主: steven_xiao

sql已优化,执行计划的变更如何人为调整执行路径 ?

[复制链接]
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
11#
发表于 2011-6-1 03:39 | 只看该作者
> 在不做统计更新的计划下,这种执行计划的变更有没办法人为优化后的执行计划(主要是执行路径)?

I think you missed a word in this sentence. We have to guess what you mean. If you mean, you want the actually used plan to change without gathering stats, then as others have said, it's not worth it. The best solution is as you did: gather stats, and (if the plan hasn't changed), run a DDL to force re-parse. Relying on dynamic sampling is not a good idea and should only be used temporarily.

> In fact, we should flush shared pool

Most of the time, the whole database is not dedicated to one application. Flushing shared pool has too much impact. Even if the database runs this app only, unless too many SQLs need to be re-parsed, flushing shared pool is still not as good as pinpointing at only the bad SQLs.

Beginning with 10.2.0.4, there's a way to purge a specific cursor, further minimizing impact.

Yong Huang

使用道具 举报

回复
论坛徽章:
18
ITPUB社区OCM联盟徽章
日期:2013-04-02 09:38:102013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:06:20ITPUB十周年纪念徽章
日期:2011-11-01 16:20:28奥运纪念徽章
日期:2012-12-06 09:21:40凯迪拉克
日期:2013-08-22 14:55:37雪佛兰
日期:2014-01-22 11:02:36夏利
日期:2014-01-07 14:14:25蛋疼蛋
日期:2013-05-17 15:36:26本田
日期:2013-12-12 12:00:45
12#
发表于 2011-6-1 14:51 | 只看该作者
DBMS_STATS.GATHER_TABLE_STATS ( . . .  no_invalidate=>false)

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
13#
发表于 2011-6-2 04:02 | 只看该作者
> DBMS_STATS.GATHER_TABLE_STATS ( . . .  no_invalidate=>false)

Nothing is perfect. The little problem with setting no_invalidate to false is that, if the table has indexes, then the time the stats gathering is done may significantly differ among indexes and between the indexes and the table, depending on the size. Setting no_invalidate to true gives you an opportunity to invalidate the cursors at one single point in time (the time you run a DDL). Even if you set cascade to true, the completion time of stats gathering is still different.

I haven't studied the case with partitioned tables. Each partition may have different completion time for stats gathering too.

Yong Huang

使用道具 举报

回复
论坛徽章:
86
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11优秀写手
日期:2013-12-18 09:29:11日产
日期:2013-10-17 08:44:39马自达
日期:2013-08-26 16:28:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-23 16:55:51马上有房
日期:2014-02-19 11:55:14
14#
发表于 2011-6-3 09:46 | 只看该作者
如果预先都可以“固定”下来执行计划,那还要CBO干什么?不就回归了RBO了

使用道具 举报

回复
论坛徽章:
41
马上加薪
日期:2014-02-19 11:55:14铁扇公主
日期:2012-02-21 15:02:402012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:50:44ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15ITPUB年度最佳BLOG写作奖
日期:2012-03-13 17:09:53
15#
发表于 2011-6-3 22:46 | 只看该作者
固定执行计划也可以考虑使用Oracle的OUTLINE技术。

请参考《【OUTLINE】使用Oracle Outline技术暂时锁定SQL的执行计划》(http://space.itpub.net/519536/viewspace-673010)。

secooler

使用道具 举报

回复
论坛徽章:
194
红宝石
日期:2014-05-09 08:24:37萤石
日期:2014-01-03 10:25:39奥运会纪念徽章:羽毛球
日期:2008-07-01 10:46:06奥运会纪念徽章:马术
日期:2008-07-07 17:43:24奥运会纪念徽章:射箭
日期:2008-07-25 18:07:39奥运会纪念徽章:皮划艇激流回旋
日期:2008-07-30 10:02:57奥运会纪念徽章:花样游泳
日期:2008-09-26 13:02:43奥运会纪念徽章:排球
日期:2008-12-03 11:23:272010新春纪念徽章
日期:2010-01-04 08:33:082010年世界杯参赛球队:澳大利亚
日期:2010-02-26 11:08:44
16#
发表于 2011-6-9 09:10 | 只看该作者
10,11g,可以食用sql profile。

使用道具 举报

回复
论坛徽章:
0
17#
发表于 2011-6-10 12:43 | 只看该作者
"原因可能是统计信息更新了,但没有更新share pool里的执行计划。手工做了一把grant"

system 还没有权限去查看那个表的信息?

统计信息收集后会自动应用,不是每次都是手工去刷新share pool。

使用道具 举报

回复
论坛徽章:
2
ITPUB十周年纪念徽章
日期:2011-11-01 16:24:04优秀写手
日期:2013-12-18 09:29:12
18#
 楼主| 发表于 2011-10-8 16:57 | 只看该作者
select /*+ no_merge(b) */distinct '20100101' as begindate,
                '20110523' as enddate,
                a.MAN_NO,
                b.num
  from zzlocal.imp_highcus_info a,
       (select MAN_NO, count(MSISDN) as num
          from zzlocal.imp_highcus_info
         group by MAN_NO) b
where a.MAN_NO = b.MAN_NO
   and a.MAN_NO is not null
   and (filter_flag != 1 or filter_flag is null)
   and to_char(a.imp_date, 'yyyymmdd') >= 20100101
   and to_char(a.imp_date, 'yyyymmdd') <= 20110523;

经测试,通过no_merge hint也达到了同样的效果。

使用道具 举报

回复

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

本版积分规则 发表回复

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