左右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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 通过Zimbra收取POP3邮件,总是提示错误:Connection reset

    通过Zimbra收取POP3邮件,总是提示错误:Connection reset

    2021年5月11日
    113
  • datagrip安装教程与激活 3月最新注册码

    datagrip安装教程与激活 3月最新注册码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
    95
  • 网络基础之网络协议

    一.操作系统基础操作系统:(OperatingSystem,简称OS)是管理和控制计算机硬件与软件资源的计算机程序,是直接运行在“裸机”上的最基本的系统软件,任何其他软件都必须在操作系统的支持下才

    2022年3月29日
    34
  • 自动编码器(Autoencoder)

    自动编码器(Autoencoder)autoencoder是一种无监督的学习算法。在深度学习中,autoencoder用于在训练阶段开始前,确定权重矩阵WW的初始值。神经网络中的权重矩阵WW可看作是对输入的数据进行特征转换,即先将数据编码为另一种形式,然后在此基础上进行一系列学习。然而,在对权重初始化时,我们并不知道初始的权重值在训练时会起到怎样的作用,也不知道在训练过程中权重会怎样的变化。因此一种较好的思

    2022年6月10日
    29
  • html中空格的写法[通俗易懂]

    html中空格的写法[通俗易懂]HTML不是一种编程语言,而是一种超文本标记语言(markuplanguage),是网页制作所必备的。超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素。方法1:使用键盘,键入空格在html页面中,我们可以通过键入“空格”键来插入空格。例:在p.p1中键入一个空格,在p.p2中键入5个空格。注:此时是半角状态键入“空格”:<pclass=”p1″>测试文字|HTML中文网!</p><pclass=”p2″>测试文字|HTM

    2022年6月16日
    29
  • 前端代码规范七大原则_织梦自定义表单源码

    前端代码规范七大原则_织梦自定义表单源码前言有时候我们发送手机验证码,会发现1分钟只能发送1次,这是做了频率限制,限制的时间次数,都由开发者自己决定频率认证源码分析defcheck_throttles(self,request):

    2022年7月29日
    3

发表回复

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

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