一次SQL优化分析的全过程

转载 2004年07月15日 11:26:00

作者介绍:
盖国强,曾任ITPUB MS 版版主,现任Oracle 数据库管理版版主。曾任职于某国家大
型企业,服务于烟草行业,开发过基于Oracle 数据库的大型ERP 系统,属国家信息产业部
重点工程。同时负责Oracle 数据库管理及优化,并为多家烟草企业提供Oracle 数据库管理、
优化及技术支持。目前任职于北京某电信增值业务系统提供商企业,负责数据库业务。管
理全国30 多个省点数据库平台。实践经验丰富,长于数据库诊断、优化与SQL 调整。希
望与大家共同学习提高Oracle 技术水平。
Mail: eygle@itpub.net
以下是一次SQL 优化分析的全过程,曾经在itpub 上发过相关的帖子,现在整理了一
下,添加了详细的说明,希望对大家有些帮助。
环境说明:
数据库版本:Oracle8.1.7.4
平台:Hp-Ux11i
以下是从程序员处获得的一段代码,开发人员抱怨这段代码执行缓慢,我执行该段代码
获得执行计划,分析如下:
这是该段代码的执行计划及统计数据:
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
8 rows selected.
Elapsed: 00: 00: 00.51
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 NESTED LOOPS
2 1 NESTED LOOPS
3 2 TABLE ACCESS (FULL) OF 'SP_TRANS'
4 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS_SUB'
5 4 INDEX (RANGE SCAN) OF 'PK_SP_TRANS_SUB' (UNIQUE)
6 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM'
7 6 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
4 db block gets
323 consistent gets
0 physical reads
0 redo size
1809 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
该段代码用以按供货商查询2003 年开始的处理单据(当时的数据量很少),查询时间大
约是0.51 秒。
此前这几个表都没有分析过,数据库选择的是RBO 优化器。
为了加快代码的执行,analyze 相关表:
SQL> analyze table sp_trans_sub compute statistics;
Table analyzed.
Elapsed: 00: 00: 30.64
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
8 rows selected.
Elapsed: 00: 00: 06.49
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=18577 Card=126726520
Bytes=30034185240)
1 0 MERGE JOIN (Cost=18577 Card=126726520 Bytes=30034185240)
2 1 SORT (JOIN) (Cost=14722 Card=310300 Bytes=20790100)
3 2 HASH JOIN (Cost=358 Card=310300 Bytes=20790100)
4 3 TABLE ACCESS (FULL) OF 'SP_TRANS' (Cost=43 Card=229 Bytes=8473)
5 3 TABLE ACCESS (FULL) OF 'SP_TRANS_SUB' (Cost=158 Card =135502 Bytes=4065060)
6 1 SORT (JOIN) (Cost=3855 Card=40840 Bytes=6942800)
7 6 TABLE ACCESS (FULL) OF 'SP_ITEM' (Cost=77 Card=40840 Bytes=6942800)
Statistics
----------------------------------------------------------
150 recursive calls
89 db block gets
1837 consistent gets
755 physical reads
60 redo size
1732 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
1 sorts (disk)
8 rows processed
SQL>
SQL> analyze table sp_trans compute statistics;
Table analyzed.
Elapsed: 00: 00: 13.00
SQL>
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
8 rows selected.
Elapsed: 00: 00: 01.62
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1453 Card=447198 Bytes=101066748)
1 0 NESTED LOOPS (Cost=1453 Card=447198 Bytes=101066748)
2 1 HASH JOIN (Cost=358 Card=1095 Bytes=61320)
3 2 TABLE ACCESS (FULL) OF 'SP_TRANS' (Cost=43 Card=273 Bytes=7098)
4 2 TABLE ACCESS (FULL) OF 'SP_TRANS_SUB' (Cost=158 Card=135502 Bytes=4065060)
5 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM' (Cost=1 Card= 40840 Bytes=6942800)
6 5 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
8 db block gets
1344 consistent gets
0 physical reads
0 redo size
1824 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
SQL> analyze table sp_item compute statistics
2 /
Table analyzed.
Elapsed: 00: 00: 11.67
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
8 rows selected.
Elapsed: 00: 00: 01.43
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=687 Card=1362 Bytes=128028)
1 0 HASH JOIN (Cost=687 Card=1362 Bytes=128028)
2 1 HASH JOIN (Cost=358 Card=1362 Bytes=76272)
3 2 TABLE ACCESS (FULL) OF 'SP_TRANS' (Cost=43 Card=273 Bytes=7098)
4 2 TABLE ACCESS (FULL) OF 'SP_TRANS_SUB' (Cost=158 Card=135502 Bytes=4065060)
5 1 TABLE ACCESS (FULL) OF 'SP_ITEM' (Cost=77 Card=29547 Bytes=1122786)
Statistics
----------------------------------------------------------
0 recursive calls
12 db block gets
1820 consistent gets
0 physical reads
0 redo size
1732 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
8 rows processed
当分析了所有表以后,我们发现,最后Oracle 给我选择了三个全表扫描。而且,从db
block gets 、consistent gets 全都“提高”了。
然后我在VENDOR_CODE 列上建了一个索引,试图通过索引加快代码的执行(在实际应用
中,通过添加适当的索引来加快SQL 执行是常用的方法,尤其是在RBO 模式下,但是添加索
引可能改变很多相关SQL 的执行计划,是否获得确切的性能提高,需要进行相应的测试来验
证,Oracle9i 提供索引监视的功能,你可以通过ALTER INDEX .. MONITORING USAGE 语句
来收集索引的使用信息,以确认索引是否被正常使用):
SQL> create index idx_vendor on sp_trans(vendor_code);
索引已创建。
已用时间: 00: 00: 02.03
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
已选择8 行。
已用时间: 00: 00: 01.42
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=646 Card=1362 Bytes= 128028)
1 0 HASH JOIN (Cost=646 Card=1362 Bytes=128028)
2 1 HASH JOIN (Cost=317 Card=1362 Bytes=76272)
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS' (Cost=2 Card=273 Bytes=7098)
4 3 INDEX (RANGE SCAN) OF 'IDX_VENDOR' (NON-UNIQUE) (Cost=1 Card=273)
5 2 TABLE ACCESS (FULL) OF 'SP_TRANS_SUB' (Cost=158 Card=135502 Bytes=4065060)
6 1 TABLE ACCESS (FULL) OF 'SP_ITEM' (Cost=77 Card=29547 Bytes=1122786)
Statistics
----------------------------------------------------------
0 recursive calls
8 db block gets
1546 consistent gets
1 physical reads
0 redo size
1732 bytes sent via SQL*Net to client
425 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
现在数据库使用了这个索引,执行计划稍好了一点,可是效果仍然不让人满意。
然后我删后来创建的索引,添加Rule 提示,这是我们得到了最初的执行计划
SQL> SELECT /*+ rule */ "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
已选择8 行。
已用时间: 00: 00: 00.71
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=HINT: RULE
1 0 NESTED LOOPS
2 1 NESTED LOOPS
3 2 TABLE ACCESS (FULL) OF 'SP_TRANS'
4 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS_SUB'
5 4 INDEX (RANGE SCAN) OF 'PK_SP_TRANS_SUB' (UNIQUE)
6 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM'
7 6 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
4 db block gets
323 consistent gets
0 physical reads
0 redo size
1809 bytes sent via SQL*Net to client
426 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
然后我们再次创建这个索引,得出的时间大大缩短(为存在性能问题的数据库查询添加
必要的索引,是DBA 解决问题的重要手段之一):
SQL> create index idx_vendor on sp_trans(vendor_code);
索引已创建。
已用时间: 00: 00: 02.43
SQL> SELECT /*+ rule */ "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_ITEM",
14 "SP_TRANS_SUB",
15 "SP_TRANS"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
已选择8 行。
已用时间: 00: 00: 00.31
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=HINT: RULE
1 0 NESTED LOOPS
2 1 NESTED LOOPS
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS'
4 3 INDEX (RANGE SCAN) OF 'IDX_VENDOR' (NON-UNIQUE)
5 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS_SUB'
6 5 INDEX (RANGE SCAN) OF 'PK_SP_TRANS_SUB' (UNIQUE)
7 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM'
8 7 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
49 consistent gets
1 physical reads
0 redo size
1809 bytes sent via SQL*Net to client
426 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
然而这不是最快的,这是RBO
我们修改optimizer_index_cost_adj 这个初始化参数,然后再来查看该SQL 的执行计
划。
SQL> alter session set optimizer_index_cost_adj=30
2 /
会话已更改。
已用时间: 00: 00: 00.20
SQL> SELECT "SP_TRANS"."TRANS_NO",
2 "SP_TRANS_SUB"."ITEM_CODE",
3 "SP_ITEM"."ITEM_NAME",
4 "SP_ITEM"."CHART_ID",
5 "SP_ITEM"."SPECIFICATION",
6 "SP_TRANS_SUB"."COUNTRY",
7 "SP_TRANS_SUB"."QTY",
8 "SP_TRANS_SUB"."PRICE",
9 "SP_TRANS"."VENDOR_CODE",
10 "SP_TRANS"."PAY_MODE",
11 NVL("SP_TRANS_SUB"."PAY_QTY",0),
12 0 as PAY_THIS
13 FROM "SP_TRANS",
14 "SP_ITEM",
15 "SP_TRANS_SUB"
16 WHERE ( "SP_TRANS_SUB"."TRANS_NO" = "SP_TRANS"."TRANS_NO" ) and
17 ( "SP_ITEM"."ITEM_CODE" = "SP_TRANS_SUB"."ITEM_CODE" ) and
18 ( ( "SP_TRANS"."VENDOR_CODE" = '20011021023') )
19 /
已选择8 行。
已用时间: 00: 00: 00.11
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=658 Card=1095 Bytes= 102930)
1 0 NESTED LOOPS (Cost=658 Card=1095 Bytes=102930)
2 1 NESTED LOOPS (Cost=329 Card=1095 Bytes=61320)
3 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS' (Cost=1 Card=273 Bytes=7098)
4 3 INDEX (RANGE SCAN) OF 'IDX_VENDOR' (NON-UNIQUE) (Cost=1 Card=273)
5 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS_SUB' (Cost= 2 Card=135502
Bytes=4065060)
6 5 INDEX (RANGE SCAN) OF 'PK_SP_TRANS_SUB' (UNIQUE) (Cost=3 Card=135502)
7 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM' (Cost=1 Card=29547 Bytes=1122786)
8 7 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
49 consistent gets
0 physical reads
0 redo size
1809 bytes sent via SQL*Net to client
426 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
我们来看看以下两个参数对于CBO 的巨大影响:
OPTIMIZER_INDEX_CACHING
这个初始化参数代表一个百分比,取值范围在0 到99 之间.
缺省值是0,代表当CBO 使用索引访问数据时,在内存中发现数据的比率是0%,这
意味着通过索引访问数据将需要产生物理读取,代价昂贵。如果使用缺省设置,Oracle
评估成本的时候,很多时候就会错误的选择全表扫描。
OPTIMIZER_INDEX_COST_ADJ
这个初始化参数代表一个百分比,取值范围在1 到10000 之间.
该参数表示索引扫描和全表扫描成本的表较。缺省值100 表示索引扫描成本等于全
表扫描。
这些参数对于CBO 的执行具有重大影响,其缺省值对于数据库来说通常需要调整。
一般来说对于OPTIMIZER_INDEX_CACHING 可以设置为90 左右
对于大多数OLTP 系统,OPTIMIZER_INDEX_COST_ADJ 可以设置在10 到50 之间。对于数
据仓库和DSS 系统,可能不能简单的把OPTIMIZER_INDEX_COST_ADJ 设置为50,通常我
们需要反复调整取得一个合理值.
SQL> drop index idx_vendor;
索引已丢弃。
已用时间: 00: 00: 00.61
SQL> /
已选择8 行。
已用时间: 00: 00: 00.11
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=700 Card=1095 Bytes= 102930)
1 0 NESTED LOOPS (Cost=700 Card=1095 Bytes=102930)
2 1 NESTED LOOPS (Cost=371 Card=1095 Bytes=61320)
3 2 TABLE ACCESS (FULL) OF 'SP_TRANS' (Cost=43 Card=273 Bytes=7098)
4 2 TABLE ACCESS (BY INDEX ROWID) OF 'SP_TRANS_SUB' (Cost= 2 Card=135502
Bytes=4065060)
5 4 INDEX (RANGE SCAN) OF 'PK_SP_TRANS_SUB' (UNIQUE) (Cost=3 Card=135502)
6 1 TABLE ACCESS (BY INDEX ROWID) OF 'SP_ITEM' (Cost=1 Card= 29547 Bytes=1122786)
7 6 INDEX (UNIQUE SCAN) OF 'PK_SP_ITEM' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
4 db block gets
323 consistent gets
0 physical reads
0 redo size
1809 bytes sent via SQL*Net to client
426 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
8 rows processed
SQL>
相关文档:
以下文档都是相当好的阅读材料,有兴趣的可以仔细阅读:
关于optimizer_index_cost_adj 等影响CBO 的参数及设置:
http://www.evdbt.com/SearchIntelligenceCBO.doc
关于成本的计算等,请参考以下文章:
http://www.centrexcc.com/A%20Look%20under%20the%20Hood%20of%20CBO%20-%20the%201
0053%20Event.pdf
http://www.centrexcc.com/A%20Look%20under%20the%20Hood%20of%20CBO%20-%20the%201
0053%20Event.ppt
关于CBO,请参考以下文档:
http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database
_id=NOT&p_id=35934.1
http://www.itpub.net/showthread.php?threadid=88905
关于执行计划的设置,请参考:
http://osi.oracle.com/~tkyte/article1/autotrace.html

Bootchart分析Android6.0开机性能

Bootchart是一个用于Linux启动过程性能分析的开源软件工具,以可视化的方式对GUN/Linux的开机启动过程进行性能分析,包括资源的使用(如CPU,磁盘等),各进程的执行时间信息等。根据分析...
  • whurs
  • whurs
  • 2017年03月27日 22:53
  • 1809

oracle sql优化一个案例

原sql SELECT (select t.product_name from td_b_product t where t.product_id=a.product_id ) as prod...

Oracle SQL执行计划与优化

目录 系统函数Userenv00、准备工作作业1ROWID、ROWNUM分析Oracle索引扫描四大类DML语句-MERGEDML语句-CALLEXPLAIN PLAN总结oracle tabl...

关联查询SQL的一次优化过程

本博文出自51CTO博客gaochaojs博主,有任何问题请进入博主页面互动讨论! 博文地址:http://jncumter.blog.51cto.com/812546/1620406 ...

记录一次sql优化过程

对于我这种刚刚进入DBA行业的人来说sql优化是一件很难的事情。所以今天看了一下别人优化的过程顺手记录的一笔。 SELECT DISTINCT vi.policy_no FROM odsdat...

记一次ListView性能优化全过程

本文原创,转载请注明地址:http://kymjs.com/code/2015/11/09/01 奇葩需求催生创新,记一次对 ListView 的性能优化。(当然,RecyclerView 也是一...
  • kymjs
  • kymjs
  • 2015年11月27日 10:12
  • 1198

一次数据分析的全过程

刚下完班的时候,在公司无聊的坐着,一位同事拿了一些数据给我,说让我实现一个类似交叉表格的统计报表。 源数据就是个日志文本信息2008/1/11               02:14:33:181  ...

sql2java:一次外科手术式的bug修复过程

我接触的第一个也是目前唯一的ORM工具就是鲜为人知的sql2java,这个名字倒是很容易顾名思义,一看就知道是自动生成数据库访问代码(java)的code generator. 关于它的使用介绍,参...
  • 10km
  • 10km
  • 2017年07月14日 12:04
  • 2656

Sql语句 循环调用存储过程 设置1秒执行一次!

一个日结的存储过程P_Wms_StockDailyState 参数是格式是'yyyy-MM-dd' 这个存储过程必须一天结算一次!比如在每天的几点几时几分执行这个存储过程! 现在呢 想把之前的...

Sql server存储过程以及一次插入多条记录

首先简单介绍sql server存储过程吧。至于概念含义啥的就不做过多介绍了。它其实和mysql有些类似,语法大同小异。 还是用例子说明问题吧。 CREATE PROCEDURE insert_s...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:一次SQL优化分析的全过程
举报原因:
原因补充:

(最多只允许输入30个字)