zoukankan      html  css  js  c++  java
  • 执行计划中的参数解释

    执行计划中的各个参数解释:

    一、Recursive calls (递归调用)

    1、参考:Oracle Database Reference, 10g Release 2 (10.2).pdf第916页

          Number of recursive calls generated at both the user and system level. Oracle maintains tables used for internal processing. When Oracle needs to make a change to these tables, it internally generates an internal SQL statement, which in turn generates a recursive call。

        在用户和在系统级别,都会生成recursive calls,Oracle维护了一些表用于内部的处理(数据字典)。当Oracle需要对这些表进行修改的时候,在Oracle内部生成了一些SQL语句,将会产生 recursive call

    2、参考:Oracle Database Performance Tuning Guide, 11g Release 1 (11.1).pdf第470页

          Sometimes, in order to execute a SQL statement issued by a user, Oracle must issue additional statements. Such statements are called recursive calls or recursive SQL statements. For example, if you insert a row into a table that does not have enough space to hold that row, then Oracle makes recursive calls to allocate the space dynamically. Recursive calls are also generated when data dictionary information is not available in the data dictionary cache and must be retrieved from disk.
            If recursive calls occur while the SQL Trace facility is enabled, then TKPROF produces statistics for the recursive SQL statements and marks them clearly as recursive SQL statements in the output file. You can suppress the listing of Oracle internal recursive calls (for example, space management) in the output file by setting the SYS command-line parameter to NO. The statistics for a recursive SQL statement are included in the listing for that statement, not in the listing for the SQL statement that caused the recursive call. So, when you are calculating the total resources required to process a SQL statement, consider the statistics for that statement as well as those for recursive calls caused by that statement

          为了执行一个用户发出的SQL语句,Oracle必须发出一些额外的SQL语句,这些语句称为recursive calls,例如,当你向一个表插入一行数据的时候,这个表没有多于的空间来存储这一行数据,Oracle就会产生 recursive calls来动态的分配存储空间,Recursive calls在数据字典信息数据字典缓存不可用的情况下并且必须从磁盘中重新读取的情况下也会生成。

        如果在发送递归调用的时候,SQL跟踪生效的话,那么TKPROF将会对递归SQL生成统计信息,并且将它们输出到一个文件中,递归调用的语句包含在这些递归语句中,而不是引起这些递归调用的语句中,所以当统计SQL语句执行过程中消耗的资源时,也需要考虑在SQL语句执行中引起的递归调用所消耗的资源。

    3、参考:http://www.cnblogs.com/chinhr/archive/2009/03/14/1412100.html

         In short, recursive calls are basically SQL performed on behalf of your SQL. So, if you had to parse the query, for example, you might have had to run some other queries to get data dictionary information. These would be recursive calls. Space management, security checks, calling PL/SQL from SQL—all incur recursive SQL calls.

       简单的说,递归调用是自己的SQL调用的代表,当你需要解析SQL的时候,你需要调用其他的查询去获取数据字典的信息,这些就是递归调用,空间管理,安全检查,调用PL/SQL和SQL,这些都是递归调用。

    4、 Beginning Oracle Database 11g Administration: From Novice to Professional-394页

            Recursive calls result from all the work that is done behind the scenes by Oracle before it can begin executing your query. When a query is submitted for execution, Oracle first checks its syntax. It then checks the semantics—that is, it de- references synonyms and views and identifies the underlying tables. It then computes the signature (a.k.a. hash value) of the query and checks its cache of query execution
    plans for a reusable query plan that corresponds to that signature. If a query plan is not found, Oracle has to construct one; this results in recursive calls. The number of recursive calls required can be large if the information Oracle needs to construct the query plan is not available in the dictionary cache and has to be retrieved from the database or if there are no statistics about tables mentioned in the query and data blocks have to be sampled to generate statistics dynamically.

           递归调用是在Oracle执行查询之后开始做的。当一个查询开始执行的时候,Oracle首先检查它的语义,随后检查同义词和视图中引用到的表,计算查询语句的签名(hash值),并查询缓存中是否存在当前签名的执行计划,或者查询语句的执行计划没有发现,那么它将会创建一个,这就是递归调用,当需要创建的执行计划的一些信息在数据字典缓存中不存在,需要重数据库中读取,或者查询使用的表没有统计信息,递归调用的数量会非常的大,这时候,会进行动态的取样来生成统计信息。

    二:DB block gets

         1、DB block gets is the number of times Oracle needs the latest version of a data block. Oracle does not need the latest version of a data block when the data is simply being read by the user. Instead, Oracle needs the version of the data block that was current when the query started. The latest version of a data block is typically required when the intention is to modify the data.

          DB block gets是Oracle需要获取最新版本数据所需要访问的数据块,当用户读取数据时,Oracle需要的不是最新版本的数据块的信息,而是当查询开始的时候,那个版本的数据块信息,当Oracle修改数据的时候,Oracle需要最数据块最新版本的信息。

        2、Number of times a CURRENT block was requested.  Current mode blocks are retrieved as they exist right now, not in a consistent read fashion. Normally, blocks retrieved for a query are retrieved as they existed when the query began. Current mode blocks are retrieved as they exist right now, not from a previous point in time.  During a SELECT, you might see current mode retrievals due to reading the data dictionary to find the extent information for a table to do a full scan (because you need the "right now" information, not the consistent read). During a modification, you will access the blocks in current mode in order to write to them. 
    (DB Block Gets:请求的数据块在buffer能满足的个数)

        在某个时间点需要访问的数据块的数量,当前模式的数据块是从现在存在的块进行检索,而不是一致读的模式,通常,一个查询需要获取的数据块是当查询开始的时候计算,而当前模式从从现在开始的时间读取,而不是从过去的某个时间点开始读取,在一个查询中,你需要访问数据字典进行一个全表扫描获取数据字典的段信息。在修改数据的过程中,需要访问当前模式的数据来修改写入它。

    DB block gets分为以下两种情况:

    db block gets direct:Number of times a CURRENT block was requested bypassing the buffer cache (for example, a direct load operation). This is a subset of "db block gets" statistics value.

    db block gets from cache:Number of times a CURRENT block was requested from the buffer cache. This is a subset of "db block gets" statistics value.

    三:Consistent gets (a.k.a:also know as):Beginning Oracle Database 11g Administration: From Novice to Professional-412页

          Consistent gets, a.k.a. logical reads, is the number of operations to retrieve a consistent version of a data block that were performed by Oracle while constructing query plans and while executing queries. Remember that all data blocks read during the execution of any query are the versions that were current when the query started; this is called read consistency. One of the principal objectives of query tuning is to reduce the number of consistent get operations that are required.

         一致读,也叫逻辑读,是Oracle在执行查询的时候,构建查询计划访问数据块一致版本的操作,记住:Oracle获取的所以数据块都是查询开始时候的版本,这叫做读一致性,优化查询的一个原则是减少一致读的操作。

          Consistent Gets. Number of times a consistent read was requested for a block.  This is how many blocks you processed in "consistent read" mode. This will include counts of blocks read from the rollback segment in order to roll back a block.  This is the mode you read blocks in with a SELECT, for example.  Also, when you do a searched UPDATE/DELETE, you read the blocks in consistent read mode and then get the block in current mode to actually do the modification。

        一致读,Oracle一致读请求的块的数量,也就是在进行一致读模式的时候,需要处理的数据块,则需要从回滚段读取回滚的数据块。

          Number of times a user process has applied rollback entries to perform a consistent read on the block Work loads that produce a great deal of consistent changes can consume a great deal of resources. The value of this statistic should be small in relation to the "consistent gets" statistic.

         Oracle执行一致读的时候,处理的数据块的个数。

    四:Physical reads

           Physical reads is the number of operations to read data blocks from the disks that were performed by Oracle because the blocks were not found in Oracle’s cache when they were required. The limit on the number of physical reads is therefore the number of consistent gets.

       物理读是指由于数据块在Oracle的缓存中未被发现,而需要从磁盘中读取的数据块的个数,物理读的个数是由一致读来限制的。

    五:Redo size(重做的数量)

         Redo size is the amount of information Oracle writes to the journals that track changes to the database. This metric applies only when the data is changed in some way.

    六:SQL*Net from client、SQL*Net to client

         Bytes sent via SQL*Net to client, bytes received via SQL*Net from client, and SQL*Net roundtrips to/from client are fairly self- explanatory; they track the number and size of messages sent to and from Oracle and the user

        主要是指Oracle的网络向客户端发送的数据流量的大小

    七:Sorts (memory)、sorts (disk) 

         Sorts (memory) and sorts (disk) track the number of sorting operations performed by Oracle during the course of our query. Sorting operations are performed in memory if possible; they spill onto the disks if the data does not fit into Oracle’s memory buffers. It is desirable for sorting to be performed in memory because reading and writing data to and from the disks are expensive operations. 

         最好在内存中进行排序和,在磁盘中进行数据的读和写是非常昂贵的操作。

    下面的内容是摘取自博客:http://www.cnblogs.com/chinhr/archive/2009/03/14/1412100.htm

     和Oracle Database Performance Tuning Guide, 11g Release 1 (11.1)的131页:

          

        Physical Reads通常是我们最关心的,如果这个值很高,说明要从磁盘请求大量的数据到Buffer Cache里,通常意味着系统里存在大量全表扫描的SQL语句,这会影响到数据库的性能,因此尽量避免语句做全表扫描,对于全表扫描的SQL语句,建议增 加相关的索引,优化SQL语句来解决。

    关于physical reads ,db block gets 和consistent gets这三个参数之间有一个换算公式:

    数据缓冲区的使用命中率=1 - ( physical reads / (db block gets + consistent gets) )。

    在SQL语句里体现如下:

    用以下语句可以查看数据缓冲区的命中率:

    SQL>SELECT name, value FROM v$sysstat WHERE name IN ('db block gets', 'consistent gets','physical reads');

    查询出来的结果Buffer Cache的命中率应该在90%以上,否则需要增加数据缓冲区的大小。

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

    db block gets:Number of times a CURRENT block was requested.
    consistent gets:Number of times a consistent read was requested for a block.
    physical reads:Total number of data blocks read from disk. This number equals the value of "physical reads direct" plus all reads into buffer cache.
    ---------------------------------------------------------------
    针对以上3个概念进行的说明解释及关系如下:
    1、DB Block Gets(当前请求的块数目)
    当前模式块意思就是在操作中正好提取的块数目,而不是在一致性读的情况下而产生的块数。正常的情况下,一个查询提取的块是在查询开始的那个时间点上存在的数据块,当前块是在这个时刻存在的数据块,而不是在这个时间点之前或者之后的数据块数目。
    2、Consistent Gets(数据请求总数在回滚段Buffer中的数据一致性读所需要的数据块)
    这里的概念是在处理你这个操作的时候需要在一致性读状态上处理多少个块,这些块产生的主要原因是因为由于在你查询的过程中,由于其他会话对数据块进行操 作,而对所要查询的块有了修改,但是由于我们的查询是在这些修改之前调用的,所以需要对回滚段中的数据块的前映像进行查询,以保证数据的一致性。这样就产 生了一致性读。
    3、Physical Reads(物理读)
    就是从磁盘上读取数据块的数量,其产生的主要原因是:
    1、 在数据库高速缓存中不存在这些块
    2、 全表扫描
    3、 磁盘排序
    它们三者之间的关系大致可概括为:
    逻辑读指的是Oracle从内存读到的数据块数量。一般来说是'consistent gets' + 'db block gets'。当在内存中找不到所需的数据块的话就需要从磁盘中获取,于是就产生了'phsical reads'。

  • 相关阅读:
    jquery mobile左右滑动切换页面
    用phonegap和jquery-mobile写android应用
    javascript配置ckfinder的路径
    HTML5中表单验证的8种方法
    select标签中的选项分组
    c# 冒号:C#中两个冒号(::)的作用
    jquery validate
    【C#学习笔记】检测进程是否存在并关闭
    【C#学习笔记】载入图片并居中
    【C#学习笔记】鼠标控制
  • 原文地址:https://www.cnblogs.com/caroline/p/2815646.html
Copyright © 2011-2022 走看看