关于db_block_gets了解和实验

实验

一、 自己手动创建的小表

创建一个区大小为  40k 

SYS@ORCL>show parameter db_block_size





NAME                                 TYPE        VALUE

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

db_block_size                        integer    





SYS@ORCL>create tablespace tyger1 datafile '/u01/app/oracle/oradata/ORCL/tyger1.dbf' size 10m

  2  extent management local uniform size 40k;





Tablespace created.





SYS@ORCL>create table test_db1(x int) tablespace tyger1;





Table created.





SYS@ORCL>set autotrace on 

SYS@ORCL>insert into test_db1 values(1);





1 row created.









Execution Plan

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





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

| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | INSERT STATEMENT |      |     1 |   100 |     1   (0)| 00:00:01 |

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









Statistics

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

          1  recursive calls

         19  db block gets

          1  consistent gets

          3  physical reads

        964  redo size

        675  bytes sent via SQL*Net to client

        562  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed





SYS@ORCL>insert into test_db1 values(2);





1 row created.









Execution Plan

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





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

| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | INSERT STATEMENT |      |     1 |   100 |     1   (0)| 00:00:01 |

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









Statistics

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

          1  recursive calls

          3  db block gets

          1  consistent gets

          0  physical reads

        244  redo size

        675  bytes sent via SQL*Net to client

        562  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed









2. 创建一个区 大小为80k

SYS@ORCL>create tablespace tyger2 datafile '/u01/app/oracle/oradata/ORCL/tyger2.dbf' size 10m

  2  extent management local uniform size 80k;





Tablespace created.





SYS@ORCL>create table test_db2(x int) tablespace tyger2;





Table created.





SYS@ORCL>insert into test_db2 values(1);





1 row created.









Execution Plan

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





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

| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | INSERT STATEMENT |      |     1 |   100 |     1   (0)| 00:00:01 |

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









Statistics

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

          1  recursive calls

         29  db block gets

          1  consistent gets

         28  physical reads

       1364  redo size

        675  bytes sent via SQL*Net to client

        562  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed





SYS@ORCL>insert into test_db2 values(2);





1 row created.









Execution Plan

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





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

| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | INSERT STATEMENT |      |     1 |   100 |     1   (0)| 00:00:01 |

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









Statistics

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

          1  recursive calls

          3  db block gets

          1  consistent gets

          0  physical reads

        288  redo size

        677  bytes sent via SQL*Net to client

        562  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed

结论:对于新创建的表来说。由于创建的是空表就没有对表里的空间进行分配,当插入第一条数据时,就须要对区上的块进行空间分配和对数据字典的一些操作,就会有比較大的db_block_size。

假设再次插入数据的话就基本没有对空间的分配啥的,就会有比較少的db_block_size产生。

所以对于extent指定的区大小来说  相同的空表插入相同的数据 db_block_size 可能不同。

对插入更新、删除的实验:

SYS@ORCL>update test_db1 set x=3 where x=1;





1 row updated.









Execution Plan

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

Plan hash value: 2185639234





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

| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | UPDATE STATEMENT   |          |     1 |    13 |     2   (0)| 00:00:01 |

|   1 |  UPDATE            | TEST_DB1 |       |       |            |          |

|*  2 |   TABLE ACCESS FULL| TEST_DB1 |     1 |    13 |     2   (0)| 00:00:01 |

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





Predicate Information (identified by operation id):

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





   2 - filter("X"=1)





Note

-----

   - dynamic sampling used for this statement









Statistics

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

         28  recursive calls

          1  db block gets

         11  consistent gets

          0  physical reads

        388  redo size

        678  bytes sent via SQL*Net to client

        565  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed





SYS@ORCL>delete test_db1 where x=2;





1 row deleted.









Execution Plan

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

Plan hash value: 3135214910





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

| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | DELETE STATEMENT   |          |     1 |    13 |     2   (0)| 00:00:01 |

|   1 |  DELETE            | TEST_DB1 |       |       |            |          |

|*  2 |   TABLE ACCESS FULL| TEST_DB1 |     1 |    13 |     2   (0)| 00:00:01 |

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





Predicate Information (identified by operation id):

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





   2 - filter("X"=2)





Note

-----

   - dynamic sampling used for this statement









Statistics

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

          5  recursive calls

          1  db block gets

          9  consistent gets

          0  physical reads

        288  redo size

        678  bytes sent via SQL*Net to client

        557  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed





SYS@ORCL>insert into test_db1 values(&x);

Enter value for x: 1

old   1: insert into test_db1 values(&x)

new   1: insert into test_db1 values(1)





1 row created.





。。。。

SYS@ORCL>commit;





Commit complete.





SYS@ORCL>select * from test_db1;





         X

----------

         3

         1

         2

         3

         4

         5

         6

         7

         8

         9

        19

        10

         1

        11

        12

        13

        14

        15

        16

        17

        18





21 rows selected.







SYS@ORCL>alter system flush buffer_cache;





System altered.

SYS@ORCL>update test_db1 set x=21 where x=18;





1 row updated.









Execution Plan

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

Plan hash value: 2185639234





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

| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | UPDATE STATEMENT   |          |     1 |    13 |     2   (0)| 00:00:01 |

|   1 |  UPDATE            | TEST_DB1 |       |       |            |          |

|*  2 |   TABLE ACCESS FULL| TEST_DB1 |     1 |    13 |     2   (0)| 00:00:01 |

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





Predicate Information (identified by operation id):

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





   2 - filter("X"=18)





Note

-----

   - dynamic sampling used for this statement









Statistics

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

          5  recursive calls

          1  db block gets

          9  consistent gets

          0  physical reads

        412  redo size

        678  bytes sent via SQL*Net to client

        567  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed

二、对于比較大的表来说

SYS@ORCL>create table test_db1 as select * from dba_objects;





Table created.

 

 

SYS@ORCL>insert into test_db1 values('tyger','tyger','tyger',22,23,'tyger','04-SEP-14','04-SEP-14','tyger','t','t','t','t');





1 row created.









Execution Plan

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





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

| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | INSERT STATEMENT |      |     1 |   100 |     1   (0)| 00:00:01 |

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









Statistics

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

          1  recursive calls

         15  db block gets

          1  consistent gets

          5  physical reads

       1144  redo size

        677  bytes sent via SQL*Net to client

        646  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          1  rows processed





 

 

SYS@ORCL>alter system flush buffer_cache;





System altered.





SYS@ORCL>update test_db1 set OBJECT_NAME='tom' where owner='tyger';





3 rows updated.









Execution Plan

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

Plan hash value: 2185639234





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

| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | UPDATE STATEMENT   |          |     8 |   664 |   154   (2)| 00:00:02 |

|   1 |  UPDATE            | TEST_DB1 |       |       |            |          |

|*  2 |   TABLE ACCESS FULL| TEST_DB1 |     8 |   664 |   154   (2)| 00:00:02 |

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





Predicate Information (identified by operation id):

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





   2 - filter("OWNER"='tyger')





Note

-----

   - dynamic sampling used for this statement









Statistics

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

          5  recursive calls

          3  db block gets

        769  consistent gets

        687  physical reads

        824  redo size

        679  bytes sent via SQL*Net to client

        589  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          3  rows processed

SYS@ORCL>delete test_db1 where owner='tyger';





3 rows deleted.









Execution Plan

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

Plan hash value: 3135214910





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

| Id  | Operation          | Name     | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | DELETE STATEMENT   |          |     8 |   136 |   154   (2)| 00:00:02 |

|   1 |  DELETE            | TEST_DB1 |       |       |            |          |

|*  2 |   TABLE ACCESS FULL| TEST_DB1 |     8 |   136 |   154   (2)| 00:00:02 |

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





Predicate Information (identified by operation id):

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





   2 - filter("OWNER"='tyger')





Note

-----

   - dynamic sampling used for this statement









Statistics

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

          4  recursive calls

          3  db block gets

        769  consistent gets

          0  physical reads

       1064  redo size

        679  bytes sent via SQL*Net to client

        567  bytes received via SQL*Net from client

          4  SQL*Net roundtrips to/from client

          1  sorts (memory)

          0  sorts (disk)

          3  rows processed

结论:对于占用多个段的大表来说。可能对数据改动时 对 数据字典  或者对于区、块的分配都包括在 physical reads中。

感想:

对于生产库来说,这个值一般不会太考虑究竟数字是怎么来的,由于数字都比较大,通常只关心它的尺寸大小。

版权声明:本文博主原创文章。博客,未经同意不得转载。

左右db_block_size了解和实验的更多相关文章

  1. 关于对db_block_gets的理解与实验

    实验 一. 自己手动创建的小表 创建一个区大小为  40k  SYS@ORCL>show parameter db_block_size NAME                         ...

  2. 模拟生产搭建Standby RAC实验环境(11.2.0.4 DG)

    模拟生产搭建Standby RAC实验环境(11.2.0.4 DG) 环境:RHEL 6.5 + Oracle 11.2.0.4 GI.DB 1.需求背景介绍 2.准备工作 3.主库配置 4.备库配置 ...

  3. [原] 利用 OVS 建立 VxLAN 虚拟网络实验

    OVS 配置 VxLAN HOST A ------------------------------------------ | zh-veth0(10.1.1.1) VM A | | ---|--- ...

  4. Android中Activity的四大启动模式实验简述

    作为Android四大组件之一,Activity可以说是最基本也是最常见的组件,它提供了一个显示界面,从而实现与用户的交互,作为初学者,必须熟练掌握.今天我们就来通过实验演示,来帮助大家理解Activ ...

  5. SEED实验系列文章目录

    美国雪城大学SEEDLabs实验列表 SEEDLabs是一套完整的信息安全实验,涵盖本科信息安全教学中的大部分基本原理.项目组2002年由杜文亮教授创建,目前开发了30个实验,几百所大学已采用.实验楼 ...

  6. 物联网实验4 alljoyn物联网实验之手机局域网控制设备

    AllJoyn开源物联网协议框架,官方描述是一个能够使连接设备之间进行互操作的通用软件框架和系统服务核心集,也是一个跨制造商来创建动态近端网络的软件应用.高通已经将该项目捐赠给了一个名为“AllSee ...

  7. (转)linux下和云端通讯的例程, ubuntu和openwrt实验成功(一)

    一.  HTTP请求的数据流总结#上传数据, yeelink的数据流如下POST /v1.0/device/4420/sensor/9089/datapoints HTTP/1.1Host: api. ...

  8. (原创) alljoyn物联网实验之手机局域网控制设备

    AllJoyn开源物联网协议框架,官方描述是一个能够使连接设备之间进行互操作的通用软件框架和系统服务核心集,也是一个跨制造商来创建动态近端网络的软件应用.高通已经将该项目捐赠给了一个名为“AllSee ...

  9. 实验:Oracle直接拷贝物理存储文件迁移

    实验目的:Oracle直接拷贝物理文件迁移,生产库有类似施工需求,故在实验环境简单验证一下. 实验环境: A主机:192.168.1.200 Solaris10 + Oracle 11.2.0.1 B ...

随机推荐

  1. WorkFlow介绍及用法

    WorkFlow介绍及用法 说起workflow大家肯定都不陌生,这里简单介绍一下salesforce中什么情况下使用workflow. 当你分配许多任务,定期发送电子邮件,记录修改时,可以通过自动配 ...

  2. ZOJ3626(树形dp)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4772 题意:给一棵有n个结点的树,每个点有点权表示在这个点上的价值, ...

  3. Java http数据MD5、AES、DES加密

    一,数据加密 1.提供了,md5,Hex,Sha等不可逆算法加密 2.AES加密,此加密方式瘦平台影响较重,所以只适合同类平台加密解密 3.DES自定义加密,跨平台,兼容性好 1.org.apache ...

  4. IntelliJ IDEA Groovy(转)

    更新环境变量: source /etc/profile 验证是否成功: # groovy -version Groovy Version: 2.3.6 JVM: 1.7.0_67 Vendor: Or ...

  5. linq 中执行方法

    Database1Entities db = new Database1Entities(); protected void Page_Load(object sender, EventArgs e) ...

  6. Java equals 和 hashcode 方法

    问题 面试时经常会问起字符串比较相关的问题, 总结一下,大体是如下几个: 1.字符串比较时用的什么方法,内部实现如何? 2.hashcode的作用,以及重写equal方法,为什么要重写hashcode ...

  7. JS 数字 、中文、 英文、判断

    <pre name="code" class="html">单独的验证: 利用正则表达式限制网页表单里的文本框输入内容: 用正则表达式限制只能输入中 ...

  8. C# 简化优化if/switch 表驱动法

    表示这个很强大 字典加反射,搞定多window的switch public partial class MainWindow : Window { Dictionary<string, Type ...

  9. 十分钟搞懂什么是CGI(转)

    原文:CGI Made Really Easy,在翻译的过程中,我增加了一些我在学习过程中找到的更合适的资料,和自己的一些理解.不能算是严格的翻译文章,应该算是我的看这篇文章的过程的随笔吧. CGI真 ...

  10. CF 439D(251D题)Devu and his Brother

    Devu and his Brother time limit per test 1 second memory limit per test 256 megabytes input standard ...