转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11699299

正确答案:D

SQL语句的执行过程:

1、客户端输入sql语句update t_gyj set name='gyj1' where id=1;

2、sql语句通过网络到达实例

3、server process接收sql语句,以下是执行一个sql的大致步骤(获取数据(buffer cache-->PGA)-->返数据给用户这一步只有SELECT语句中有,其它DML中没有)

sql-->sql_hash-->shared pool解析(消耗CPU)-->生成执行计划-->执行sql(buffer计算数据:逻辑读或物理读I/O)-->获取数据(buffer cache-->PGA)-->返数据给用户

当这条sql发出来时,Oracle要做些什么呢?我们先来看一张图(来自DSI405的Library cache)

在整个SGA中最复杂的就是sharedpool,而shared pool中最复杂就是library cache,这里对它的机制不做详细讨论,简单讲讲sql在里面的运作流程。

首先sql(update t_gyjset name='gyj1' where id=1)的每个字符当然包括空格转化成ASCII码后,再拿这一堆ASCII码通过HASH函数生成一个sql_hash值,Oracle拿着这个sql_hash值去描扫HASH Buckets(看上面的图,这个幅画的不太好,只画了0号的HASH BUCKETS),假如刚好sql_hash值=0,那么Oracle就延着0号HASHBuckets去搜索ObjectHandle链,在这个Object Handle上存有sql的文本,如果和我们的update t_gyj set name='gyj1' where id=1一模一样对上,那就说明这条sql已被缓存在共享池了,这个过程就是软解析。当然再往下我就不说了,再说下去很复杂了父子游标,最后执行计划是被存放在堆6中。

好,那么如果通过上面的方式在Object Handle链没搜索到这条sql的文本,那说明sql不在共享池中,这个时侯就要做硬解析(过程大要做语法,语义,权限,查询视图展开、划分小的查询块、sql等价转换、代价估算、最后生成执行计划),这个代价会有点高,如果有大量的硬解析那会消耗CPU和占用共享池。

如果这条SQL直接能在共享池的Library cache中能找到,那就是软解析。

如果想对软解析进一步优化,那就做软软解析(具体这里不深入了)

所有这些PARSE(解析)都与共享池有关。

共享池(SHARED POOL)

A、库缓存

B、数据字典缓存

C、PL/SQL区

D、SQL查询和PL/SQL函数结果缓存

答案A,不正确,与访问路径无关(是不是走索引、全表扫描、物化视图等)

答案B,不正确,SGA不能自动控制下面五个池了(BUFFER CACHE/SHARED POOL/JAVA POOL/LARGEPOOL/STREAMS POOL),因类自动共享内存关闭了。

答案C,不正解,PGA与软软解析相关,但软软解只是缓存一个游标,占用内存非常……

答案E,不正解,解析不发生在BUFFER CAHCE中,BUFFERCACHE中一般是修改和访问数据―――执行sql(buffer计算数据:逻辑读或物理读I/O)-->获取数据(buffer cache-->PGA)。

共享池参考官方文档的CONCEPTS:

Shared Pool

The shared pool caches various types of program data. For example, the shared pool stores parsed SQL, PL/SQL code, system parameters, and data dictionary information. The shared pool is involved in almost every operation that occurs in the database. For example, if a user executes a SQL statement, then Oracle Database accesses the shared pool.

The shared pool is divided into several subcomponents, the most important of which are shown in Figure 14-9.

Figure 14-9 Shared Pool

This section includes the following topics:

Library Cache

The library cache is a shared pool memory structure that stores executable SQL and PL/SQL code. This cache contains the shared SQL and PL/SQL areas and control structures such as locks and library cache handles. In a shared server architecture, the library cache also contains private SQL areas.

When a SQL statement is executed, the database attempts to reuse previously executed code. If a parsed representation of a SQL statement exists in the library cache and can be shared, then the database reuses the code, known as a soft parse or a library cache hit. Otherwise, the database must build a new executable version of the application code, known as a hard parse or a library cache miss.

Shared SQL Areas

The database represents each SQL statement that it runs in the following SQL areas:

  • Shared SQL area

    The database uses the shared SQL area to process the first occurrence of a SQL statement. This area is accessible to all users and contains the statement parse tree andexecution plan. Only one shared SQL area exists for a unique statement.

  • Private SQL area

    Each session issuing a SQL statement has a private SQL area in its PGA (see "Private SQL Area"). Each user that submits the same statement has a private SQL area pointing to the same shared SQL area. Thus, many private SQL areas in separate PGAs can be associated with the same shared SQL area.

The database automatically determines when applications submit similar SQL statements. The database considers both SQL statements issued directly by users and applications and recursive SQL statements issued internally by other statements.

The database performs the following steps:

  1. Checks the shared pool to see if a shared SQL area exists for a syntactically and semantically identical statement:

    • If an identical statement exists, then the database uses the shared SQL area for the execution of the subsequent new instances of the statement, thereby reducing memory consumption.

    • If an identical statement does not exist, then the database allocates a new shared SQL area in the shared pool. A statement with the same syntax but different semantics uses a child cursor.

    In either case, the private SQL area for the user points to the shared SQL area that contains the statement and execution plan.

  2. Allocates a private SQL area on behalf of the session

    The location of the private SQL area depends on the connection established for the session. If a session is connected through a shared server, then part of the private SQL area is kept in the SGA.

Figure 14-10 shows a dedicated server architecture in which two sessions keep a copy of the same SQL statement in their own PGAs. In a shared server, this copy is in the UGA, which in the large pool or in the shared pool when no large pool exists.

Figure 14-10 Private SQL Areas and Shared SQL Area


QQ:252803295

技术交流QQ群:
DSI&Core Search  Ⅰ 群:127149411(2000人技术群:未满)
DSI&Core Search  Ⅱ 群:177089463(1000人技术群:未满)
DSI&Core Search  Ⅲ 群:284596437(500人技术群:未满)
DSI&Core Search  Ⅳ 群:192136702(500人技术群:未满)
DSI&Core Search  Ⅴ 群:285030382(500人闲聊群:未满)

MAIL:dbathink@hotmail.com

BLOG: http://blog.csdn.net/guoyjoe

WEIBO:http://weibo.com/guoyJoe0218

ITPUB: http://www.itpub.net/space-uid-28460966.html

OCM:   http://education.oracle.com/education/otn/YGuo.HTM

[每日一题] 11gOCP 1z0-052 :2013-09-14 repeated parsing activity.................................A70的更多相关文章

  1. [每日一题] 11gOCP 1z0-052 :2013-09-1 RMAN-- repair failure........................................A20

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10859315 正确答案:D 一.模拟上题的错误: 1.删除4号文件 [oracle@myd ...

  2. [每日一题] 11gOCP 1z0-053 :2013-10-9 backup with the KEEP option....................................33

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12517603 正确答案:AB 在Oracle 11g中,可以使用backup ….keep ...

  3. [每日一题] 11gOCP 1z0-053 :2013-10-12 RESULT_CACHE在哪个池?.............................44

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12657479 正确答案:B   Oracle 11g 新特性:Result Cache , ...

  4. [每日一题] 11gOCP 1z0-052 :2013-08-31 数据库的存储结构....................................................A8

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10784599 . 正确答案:A 将逻辑存储与物理存储分开是关系数据库范例的必要部分.关系数 ...

  5. [每日一题] 11gOCP 1z0-052 :2013-09-19 创建用户...................................................B41

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11834661 正确答案:BC 这道题比较简单,我就以答案来解析,如下来自官方文档创建用户的 ...

  6. [每日一题] 11gOCP 1z0-052 :2013-09-17 DRA--Data Recovery Advisor.............................B31

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11818529 正确答案:AD 数据库恢复顾问(DRA)是一个诊断和修复数据库问题的工具.共 ...

  7. [每日一题] 11gOCP 1z0-052 :2013-09-5 runInstaller oracle of no swap

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11186995 正确答案:A 我们先来看下面这张截图,这是我在安装Oracle 11.2.0 ...

  8. [每日一题] 11gOCP 1z0-053 :2013-10-11 Flashback Data Archive属性.........................43

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12656897 正确答案:BD 闪回数据归档请参考:http://blog.csdn.net ...

  9. [每日一题] 11gOCP 1z0-053 :2013-10-7 the backup of MULT_DATA................................32

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12500579 正确答案:D      RMAN 的新增功能 对超大型文件应用 Intraf ...

随机推荐

  1. webservice跨域上传图片

    1.上传文件,在一般处理程序中处理 //1.接收post过来的文件 HttpPostedFile file = context.Request.Files[]; || file.ContentLeng ...

  2. Asp.Net MVC4.0 官方教程 入门指南之五--控制器访问模型数据

    Asp.Net MVC4.0 官方教程 入门指南之五--控制器访问模型数据 在这一节中,你将新创建一个新的 MoviesController类,并编写代码,实现获取影片数据和使用视图模板在浏览器中展现 ...

  3. C++如何将一个整数输出为小数

    double a=3;                      //一定是double不能是int cout.setf(ios::fixed); cout.precision(2); cout< ...

  4. 13-C语言字符串函数库

    目录: 一.C语言字符串函数库 二.用命令行输入参数 回到顶部 一.C语言字符串函数库 1 #include <string.h> 2 字符串复制 strcpy(参数1,参数2); 参数1 ...

  5. IList, ICollection ,IEnumerable AND IEnumerator in C#

    IList, ICollection ,IEnumerable 很显然,这些都是集合接口的定义,先看看定义: // 摘要: // 表示可按照索引单独访问的对象的非泛型集合. [ComVisible(t ...

  6. Python中type与Object的区别

    Python中type与Object的区别 在查看了Python的API后,总算明白了.现在总结如下: 先来看object的说明: Python中关于object的说明很少,甚至只有一句话: clas ...

  7. CSS3阴影 box-shadow的使用和技巧总结[转]

    text-shadow是给文本添加阴影效果,box-shadow是给元素块添加周边阴影效果.随着html5和CSS3的普及,这一特殊效果使用越来越普遍. 基本语法是{box-shadow:[inset ...

  8. HDU 1544 Palindromes(回文子串)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1544 问题分析: 问题要求求出字符串的连续子串中的回文子串个数.首先,需要区分连续子串与子序列的区别. ...

  9. Web打印组件jatoolsPrinter(转载)

    应用web化,不论对开发商,还是对用户来说,实在是一种很经济的选择,因为基于web的应用,客户端的规则很简单,容易学习,容易维护,容易发布.但对程序员来说,因为浏览器的局限性,却要面对很多挑战.怎么样 ...

  10. 如何让HTML的编写更具结构性

    首先声明,我不是搞技术的,很多词汇写的不够专业,但作为一枚菜鸟,我站在菜鸟的角度,来讲述我在学习技术的过程中所遇到的问题,和解决的方案. 入门HTML还算简单,无非是先写好固定的三对开闭标签结构:ht ...