硬解析和物理读取与软解析和逻辑读取

简介: 参考:http://www.cnblogs.com/chinhr/archive/2009/03/14/1412100.html 001 预备知识 ·Recursive Calls:有时为了执行用户发出的一条SQL语句,Oracle必须执行额外的语句。
参考:http://www.cnblogs.com/chinhr/archive/2009/03/14/1412100.html
001 预备知识
·Recursive Calls:有时为了执行用户发出的一条SQL语句,Oracle必须执行额外的语句。这样的额外的语句被称为递归调用或者递归SQL语句。例如,如果你想往表中插入一行,但是该表没有足够的空间来容纳这行,这个时候Oracle就会使用递归调用来自动分配空间。

·db block gets: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. 


·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. 

·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. 

·Sorts (disk):Number of sort operations that required at least one disk write. Sorts that require I/O to disk are quite resource intensive. Try increasing the size of the initialization parameter SORT_AREA_SIZE. 

002 
    本文通过在3种不同场景下多次执行同一语句的区别。第一个例子在语句执行之前清空了共享池和缓冲区缓存,这意味着该语句将会被硬解析,包含该查询所需数据的块(以及为了完成硬解析所需的所有关于系统对象的查询)需要从磁盘上物理读取。第二个例子展示了如果仅清空缓冲区缓存将会发生什么。最后一个例子展示的是共享池和缓冲区都不清空的场景。

2-1 在语句执行之前清空共享池和缓冲区缓存
SYS@PROD1> alter system flush buffer_cache;

System altered.

SYS@PROD1> alter system flush shared_pool;

System altered.

SYS@PROD1> set autotrace traceonly statistics
SYS@PROD1> select * from hr.employees where department_id=60;

Statistics
----------------------------------------------------------
161  recursive calls
 0  db block gets
239  consistent gets
26   physical reads
 0  redo size
1647  bytes sent via SQL*Net to client
524  bytes received via SQL*Net from client
 2  SQL*Net roundtrips to/from client
 9  sorts (memory)
 0  sorts (disk)
 5  rows processed



SYS@PROD1> set autotrace off

2-2 仅清空缓冲区缓存

SYS@PROD1> alter system flush buffer_cache;

System altered.

SYS@PROD1> set autotrace traceonly statistics
SYS@PROD1> select * from hr.employees where department_id=60;

Statistics
----------------------------------------------------------
 0  recursive calls
 0  db block gets
 4  consistent gets
 2  physical reads
 0  redo size
1647  bytes sent via SQL*Net to client
524  bytes received via SQL*Net from client
 2  SQL*Net roundtrips to/from client
 0  sorts (memory)
 0  sorts (disk)
 5  rows processed


2-3 共享池和缓冲区都不清空
SYS@PROD1> select * from hr.employees where department_id=60;

Statistics
----------------------------------------------------------
 0  recursive calls
 0  db block gets
 4  consistent gets
 0  physical reads
 0  redo size
1647  bytes sent via SQL*Net to client
524  bytes received via SQL*Net from client
 2  SQL*Net roundtrips to/from client
 0  sorts (memory)
 0  sorts (disk)
 5  rows processed

SYS@PROD1> set autotrace off

003 结论
     可以从统计信息中看到,当执行的查询仅需软解析并且能够从缓冲区缓存中读取数据块时,执行任务所耗用的资源是最少的。
我们的目标应该永远是开发出能够更多地重用共享池和缓冲区缓存中信息的代码。

相关文章
|
7月前
|
存储 区块链 数据安全/隐私保护
DApp互助预约排单系统开发设计规则逻辑解析
DApp互助预约排单系统开发设计规则逻辑解析
|
8月前
|
Web App开发 前端开发 JavaScript
Dapp技术开发全解析丨附DAPP源码的逻辑实例解析
智能合约是Dapp的核心组成部分,它是一种基于区块链技术的自动化合约,可以执行预定义的操作和条件。智能合约的执行是去中心化的,可以在区块链上自动执行,无需中间方参与。智能合约的开发需要熟悉Solidity等编程语言,同时需要了解智能合约的安全性问题。
|
3月前
|
编解码 计算机视觉 Python
IPC机制在jetson中实现硬解码视频流数据通信的逻辑解析
IPC机制在jetson中实现硬解码视频流数据通信的逻辑解析
50 0
|
3月前
|
存储 SQL 关系型数据库
drds逻辑表与物理解析
drds逻辑表与物理解析
25 5
|
4月前
|
测试技术 数据库
深入解析MyBatis-Plus中的逻辑删除功能及实例
深入解析MyBatis-Plus中的逻辑删除功能及实例
256 0
|
7月前
|
XML JavaScript 前端开发
SAP UI5 Fiori Elements annotation 的解析逻辑 AnnotationParser.js
SAP UI5 Fiori Elements annotation 的解析逻辑 AnnotationParser.js
40 0
|
7月前
|
XML API 数据格式
SAP UI5 ManagedObject 的 Event 讲解以及 SAP UI5 XML 视图里控件 press 的解析逻辑
SAP UI5 ManagedObject 的 Event 讲解以及 SAP UI5 XML 视图里控件 press 的解析逻辑
46 0
|
8月前
|
JSON 数据格式
通过一个实际例子,讲解 SAP UI5 Compatibility Version 的概念和运行时绑定解析器的选择逻辑
通过一个实际例子,讲解 SAP UI5 Compatibility Version 的概念和运行时绑定解析器的选择逻辑
33 0
|
8月前
|
前端开发 测试技术 API
SAP UI5 Theme Library 的解析逻辑和 SAP UI5 配置元数据的默认值
SAP UI5 Theme Library 的解析逻辑和 SAP UI5 配置元数据的默认值
43 0
|
8月前
|
存储 安全 数据处理
Dapp区块链软件开发丨DAPP源码的逻辑规则解析
DApp 是一种去中心化、开放源码的分布式应用程序。DApp 可以提供多种功能和服务,如智能合约、数字钱包、交易服务、联网身份认证等。DApp 有许多与传统应用程序相似的功能,但其主要特征是去中心化、透明度、程序代码智能、自治性和数据不可篡改性。

推荐镜像

更多