Oracle性能调优自己总结的18条经验

1.      查看具体语句的执行计划及消耗的内存/CPU量

当前两张表中各有数据1508875条

原始语句为:

SELECT/*+rule*/ JB.RYID, JB.GMSFHM,JB.XM, JB.XB, JB.CSRQ, ZP.ZP

FROMHZCZRK_JBXXB JB,HZCZRK_ZPXXB ZP

WHEREJB.RYID = ZP.RYID

AND ( JB.RYID>= 1 AND JB.RYID < 10001)

采用以下方式可以获得该语句的执行计划:

执行计划

----------------------------------------------------------

Plan hashvalue: 2567408823

 

--------------------------------------------

| Id  | Operation           | Name         |

--------------------------------------------

|   0 | SELECT STATEMENT    |              |

|   1 | MERGE JOIN         |              |

|   2 |  SORT JOIN         |              |

|   3 |   TABLE ACCESS FULL| HZCZRK_ZPXXB |

|*  4 |  SORT JOIN         |              |

|*  5 |   TABLE ACCESS FULL| HZCZRK_JBXXB |

--------------------------------------------

 

PredicateInformation (identified by operation id):

---------------------------------------------------

 

   4 -access("JB"."RYID"="ZP"."RYID")

       filter("JB"."RYID"="ZP"."RYID")

   5 -filter("JB"."RYID"<10001 AND"JB"."RYID">=1)

 

Note

-----

   - rule based optimizer used (consider usingcbo)

 

 

统计信息

----------------------------------------------------------

          2 recursive calls

          1 db block gets

        544 consistent gets

          0 physical reads

        176 redo size

      11999 bytes sent via SQL*Net to client

        811 bytes received via SQL*Net from client

          7 SQL*Net roundtrips to/from client

          2 sorts (memory)

          0 sorts (disk)

         79  rows processed

如果不设置总行数,则执行计划是:

执行计划

----------------------------------------------------------

Plan hashvalue: 2567408823

 

--------------------------------------------

| Id  | Operation           | Name         |

--------------------------------------------

|   0 | SELECT STATEMENT    |              |

|   1 | MERGE JOIN         |              |

|   2 |  SORT JOIN         |              |

|   3 |   TABLE ACCESS FULL| HZCZRK_ZPXXB |

|*  4 |  SORT JOIN         |              |

|   5 |   TABLE ACCESS FULL| HZCZRK_JBXXB |

--------------------------------------------

 

PredicateInformation (identified by operation id):

---------------------------------------------------

 

   4 - access("JB"."RYID"="ZP"."RYID")

      filter("JB"."RYID"="ZP"."RYID")

 

Note

-----

   - rule based optimizer used (consider usingcbo)

 

 

统计信息

----------------------------------------------------------

          2 recursive calls

          1 db block gets

       1103 consistent gets

          0 physical reads

        176 redo size

      23915 bytes sent via SQL*Net to client

        866 bytes received via SQL*Net from client

         12 SQL*Net roundtrips to/from client

          2 sorts (memory)

          0  sorts(disk)

        164  rows processed

这里我们主要需要关注两个点:consistent gets代表内存消耗,physical reads代表磁盘I/O消耗,单位都是数据块(DB_BLOCK_SIZE)。

从上面的执行计划可以看出表之间的连接关系基本上就是采用排序合并连接技术,所以下面对连接技术做出一些说明

适合于大批量数据处理的连接技术只有两种:

1.    排序合并连接(Sort/Merge)技术

两个表先按连接字段进行排序,再将两个表的排序结果进行顺序匹配,将合并结果返回给客户。

2.    哈希连接(HASH)技术

A hashjoin is executed as follows:

Bothtables are split into as many partitions as required, using a full table scan.

For eachpartition pair, a hash table is built in memory on the smallest partition.

The otherpartition is used to probe the hash table.

两种技术都适合于大表与大表的查询,而且通常情况下,HASH优于Merge,更优于嵌套循环(Nested_Loop)连接技术,尤其是当HASH与Oracle并行处理技术相结合的情况下,将极大地提高系统的整体吞吐量。

 

2.      对两张表做一个分析

由于从Oracle10G开始已经不采

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Database Performance Tuning and Optimization Publisher: Springer | Pages: 510 | 2002-12-13 | ISBN: 0387953930 | PDF | 2 MB Product Description: Examples abound in database applications of well-formulated queries running slowly, even if all levels of the database are properly tuned. It is essential to address each level separately by focusing first on underlying principles and root causes, and only then proposing both theoretical and practical solutions. "Database Performance Tuning and Optimization" comprehensively addresses each level separately by focusing first on underlying principles and root causes, and then proposes both theoretical and practical solutions using Oracle 8i examples as the RDBMS. The book combines theory with practical tools (in the form of Oracle and UNIX shell scripts) to address the tuning and optimization issues of DBAs and developers, irrespective of whether they use Oracle. Topics and features: * An integrated approach to tuning by improving all three levels of a database (conceptual, internal, and external) for optimal performance * Balances theory with practice, developing underlying principles and then applying them to other RDBMSs, not just Oracle * Includes CD-ROM containing all scripts and methods utilized in the book * Coverage of data warehouses provides readers much needed principles and tools for tuning large reporting databases * Coverage of web-based databases * Appendix B shows how to create an instance and its associated database and all its objects * Provides useful exercises, references, and Oracle 8i and select 9i examples Based on nearly two decades of experience as an Oracle developer and DBA, the author delivers comprehensive coverage of the fundamental principles and methodologies of tuning and optimizing database performance. Database professionals and practitioners with some experience developing, implementing, and maintaining relational databases will find the work an essential resource. It is also suitable for professional short courses and self-study purposes.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值