September 2010
M T W T F S S
« Jul    
 12345
6789101112
13141516171819
20212223242526
27282930  

cardinality feedback

Kaya 发表于 os2ora.com

到了10g的时代,cardinality feedback这个词正在变得越来越流行。我想,开始导致这个词流行的或许不是来自Oracle官方的推广,而是来自Wolfgang Breitling在Hotsos Symposium 2006上的一个演讲: Tuning by Cardinality Feedback: Method and Examples. 从作者的网站有下面的信息:

Tuning by Cardinality Feedback

Tuning by cardinality feedback looks at discrepancies between estimated and real row source cardinalities of an execution plan and attempts to find ways to correct the CBO’s error in estimation and trusting it to find a better plan based on the corrected, more accurate estimates.

Faced with an underperforming SQL, the question the TCF method is trying to answer is not
    What would be a better access plan?
But instead
    Why is this plan, which the CBO chose as optimal, performing so poorly?

Once the answer to that question is found, the next goal is to find a way to remedy the cause for the miscalculation, but ultimately get out of the way and let the CBO do its job again.

The presentation was given at the 2006 Hotsos Symposium on Oracle® System Performance March 5–9, 2006 in Dallas, Texas and at CBO Days June 21-22 in Zurich, Switzerland.

Paper  Presentation

这种方法,也是我们平常调优SQL的最主要方法。虽然以前没有专门介绍过,不过有一些文章还是偶尔提及的,例如这篇: 11gR2出色的SQL Monitor Report, 提到了用SQL Monitor Report查看actual rows与estimate rows的方法。

网上的另一个介绍cardinality feedback的演讲可以参考这一篇,http://jonathanlewis.wordpress.com/2009/05/11/cardinality-feedback/,作者是Michelle Deng,Sanofi Aventis.注意这里已经是2009年的事情了。

看看Oracle内部开发人员的演讲吧,这是VLDB 2008上的一个演讲.

Allison W. Lee, Mohamed Zaït: Closing the query processing loop in Oracle 11g: Paper, Presentation

这俨然成为了11g的一个new feature,如何你手头有Oracle 11g,你甚至现在就可以演练一下。

下面是一个用到了cardinality feedback的执行计划,注意最后一行: cardinality feedback used for this statement

 

---------------------------------------------------------------------------------------------------------------
| Id  | Operation                      | Name                         | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |                              |       |       | 98089 (100)|          |
|   1 |  SORT ORDER BY                 |                              |     1 |    97 | 98089   (1)| 00:19:38 |
|*  2 |   HASH JOIN                    |                              |     1 |    97 | 98088   (1)| 00:19:38 |
|   3 |    VIEW                        | VW_NSO_1                     |     4 |    36 | 47108   (1)| 00:09:26 |
|   4 |     SORT UNIQUE                |                              |     4 |   148 | 47108  (51)| 00:09:26 |
|   5 |      UNION-ALL                 |                              |       |       |            |          |
|*  6 |       TABLE ACCESS STORAGE FULL| TA                           |     2 |    62 | 23549   (1)| 00:04:43 |
|*  7 |       TABLE ACCESS STORAGE FULL| TA                           |     2 |    86 | 23558   (1)| 00:04:43 |
|*  8 |    TABLE ACCESS STORAGE FULL   | TB                           |   469K|    39M| 50978   (1)| 00:10:12 |
---------------------------------------------------------------------------------------------------------------
 
....
 
Note
-----
   - cardinality feedback used FOR this statement

可以google下”cardinality feedback”。会有人其它人的演练报告。

想想吧,以后的DBA,回顾这段历史,想想以前的人们如何用手工的方法用cardinality feedback 进行调优,是不是会和我们现在想着过去人们如何用手工方法进行space management, memory management的场景类似? evolving, evolving, evolving…

FW: Hiring Senior/Principle member-Real World Performance Group

转一个比较正式的招聘,也顺便做下广告,欢迎您的加盟。
Job description:
Real World Performance Group is part of the Oracle Database product management team. We do customer benchmarks and post-product escalations to help to shorten sales cycle, to make quality insurance of the Oracle database product, and master the competitive intelligence of the Oracle database product. We are a global team including people in US, [...]

Exadata V2 架构分析 (6)

从第一篇开始到现在,Cell Flash Cache, Exadata Hybrid Columnar Compression, Storage Index轮番上场,加上V1版本里出现的Smart Scan,Infiniband等等,多少会给人以眼花缭乱的感觉。

最根本的一点,当然在于Exadata本身是一个balanced system。

不过,这些技术做为一个整体对实际应用会带来多大的好处呢?这不是一个很好回答的问题,当然也可以用一句话回答——具体问题具体分析……

Exadata V2 架构分析 (5)

Exadata上另一个聪明的软件设计是实现了storage index.
如果Exadata给你的印象就是有很强大的硬件,却不会利用传统的性能优化方法,比如索引,去加快查询速度的话,那么Storage Index的出现或许会改变你的这种观念。而且,storage index是完全自动化的,它甚至不需要人工的干涉就能工作得很好……

Exadata V2 架构分析 (4)

下一个要出场的是HCC, Hybrid Columnar Compression. 目前它是Exadata上面才有的一个特性。
在Exadata V2 架构分析 (1)中,曾提到“在软件设计上,还有另一个重头戏,它更是大大的利用起了存贮节点上的CPU处理能力,同时还能减少对带宽的争用”。Exadata的很多设计,或许从根本上讲,就在于充分利用起存贮节点上的处理能力,Smart Scan和这里所要提及的HCC,就是两个典型的代表了。HCC中文翻译过来或许就叫做混合列压缩,它是在单纯的行存贮和列存贮之间取得的一个折衷……

招聘

Kaya 发表于 os2ora.com
RWP(Oracle RealWorld Database Performance Group)准备在中国多招一员干将,有没朋友有兴趣。工作地点最好在深圳,北京也可以接受。工作内容主要在于性能调优(OLTP/OLAP)还有可扩展性方面,希望有这方面比较丰富的经验。
仅仅是先做个不正式的预告,不过有兴趣&&有疑问的朋友也可以给我发邮件。

无奈的DBA

在检查客户的代码中,有时会深刻地感觉到原代码编写者在调试代码时的无奈。
这使我想起以前调试代码时的经历。一个SQL迟迟不返回结果,一小时过去了,又一小时过去了…… 于是,想了好多调优的方法,调整系统参数,为这个SQL建立很多Index,加上各种各样的Hint ……
于是,现在在代码中看到似曾相识的/*+ index(t_xx, idx_xx) */时,有时会发自内心的笑了,同时,轻巧地把里面的+号删掉了,我就让这些个hint不起作用,不强迫CBO走index了,结果当然是CBO选择了Hash Join,而不是原代码编写者指定的Nested Loop,于是,执行速度嗖一下上去了。
有另一个有趣的事情……

测试: 一个SQL Monitor Report的具体例子

之前曾提到如何利用SQL Monitor Report对SQL进行诊断与调优,对于具体的SQL调优而言,SQL Monitor Report提供的信息无疑比AWR更有针对性,当然,AWR在信息的全面性方面会更胜一筹。本文提供一个具体的例子,同样的SQL,同样的执行计划,第一次执行的时间远远大于第二次执行的时间……

Exadata V2 架构分析 (3)

关于Cell Flash Cache,或许大家都余兴未尽,例如:
1. 一个真正的生产系统,真的需要1,000,000 IOPS吗?
2. Cell Flash Cache对用户带来的真正的好处在哪里?
假设用户的逻辑IOPS达到1,000,000 IO/s. buffer cache命中率为98%。则落在Cell Flash Cache中的IOPS为20,000次……

Exadata V2 架构分析 (2)

既然提到了Flash Cache,如果不提下对OLTP的提速好象会缺少点什么。对OLTP系统而言,缓存是一个极其重要的设计,不管是数据库节点上的内存上的Buffer Cache,还是存贮节点上的Flash Cache(Exadata),还有数据库节点上的Flash Cache(某些平台,如Linux)……