左右db_block_size了解和实验

左右db_block_size了解和实验

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

关于db_block_gets了解和实验

实验

一、 自己手动创建的小表

创建一个区大小为  40k 
SYS@ORCL>show parameter db_block_size

NAME                                 TYPE        VALUE
———————————— ———– ——————————
db_block_size                        integer     8192

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中。



感想:

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116932.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 实用HTML,CSS和JavaScript速查表

    实用HTML,CSS和JavaScript速查表

    2021年5月8日
    112
  • tomcat java_maven和tomcat的关系

    tomcat java_maven和tomcat的关系缓存什么是缓存[Cache]存在内存中的临时数据将用户经常查询的数据放在缓存(内存)中,用户去查询数据的时候就不用从磁盘上(关系型数据库数据文件)查询,从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题。为什么使用缓存减少和数据库的数据交换次数,较少系统开销,提高系统效率什么样的数据库能使用缓存经常查询并且不经常改变的数据Mybatis缓存MyBatis 内置了一个强大的事务性查询缓存机制,它可以非常方便地配置和定制。默认情况下,只启用了本地的会话缓存,它仅

    2022年8月8日
    7
  • Linux 常用网络指令介绍一

    Linux 常用网络指令介绍一

    2021年7月22日
    89
  • 量化进阶——量化交易模型的“钝化”与“圣杯”[通俗易懂]

    量化进阶——量化交易模型的“钝化”与“圣杯”[通俗易懂]阅读原文:http://club.jr.jd.com/quant/topic/1326857京东金融官方资讯QQ群:417082141有什么想咨询的都可以来询问我们哦钝化的烦恼常有人提到量化交易模型的“钝化”问题,通俗的说,也就是一个模型从赚大钱变为不赚钱,甚至亏损的一个过程。甚至在海洋部落那样高手云集的社会中,不少高人眼里,钝化是每个量化交易模型都会很快发生的事,赚钱机

    2022年6月26日
    37
  • sp_executesql_sp_executesql存储过程简介和示例

    sp_executesql_sp_executesql存储过程简介和示例sp_executesqlThesp_executesqlisabuilt-instoredprocedureinSQLServerthatenablestoexecuteofthedynamicallyconstructedSQLstatementsorbatches.Executingthedynamicallyconstructe…

    2022年5月22日
    27
  • buck降压电路解析

    buck降压电路解析1.拓扑模型如下2.需要的元器件如下:元器件:开关管T、续流二极管D、储能电感L、滤波电容C、负载电阻R输入电压:Ui输出电压:Uo特性:Ui>Uo3.三种工作模式BCM、CCM、DCM3.1CCM–电感电流连续导通模式3.2当Imin减小到零时,电路由CCM模式进入BCM—电感电流临界导通模式3.3DCM—电感电流非连续/断续导通模式4.举例子LM2576/2596下图中的R1/R2阻值一般是k级别电阻,100k左右,目的是减少功耗5.常见的厂商TI、MP

    2022年6月20日
    66

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号