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


相关推荐

  • android studio 导入eclipse乱码解决「建议收藏」

    android studio 导入eclipse乱码解决「建议收藏」在开发过程中遇到androidstudio导入eclipse乱码,综合网上查找的答案,我是这样解决的:1、首先在module的bulid.gradle文件的android标签中加入以下内容:applyplugin:’com.android.xxxx’android{compileSdkVersion21buildToolsVersion”21.

    2022年5月25日
  • 什么是MiniPCIe?MiniPCIe的作用是什么?「建议收藏」

    什么是MiniPCIe?MiniPCIe的作用是什么?「建议收藏」2019年,中国正式进入5G商用元年。4G网络不管是速度、还是信号上都再无优势,那么4G网络会被淘汰吗?现在物联网应用最大的承载部分是在2G/3G网络,而现在的NB-IOT网络,不适用在高速率,低延时通信场景中。以前对速率,时延有一定要求的物联网设备将会向4G的LTE网络迁移,4G网络已经足够承载相关设备。也就是说,很长一段时间内就是作为物联网的承载网络的4G网络也不会被淘汰。StrategyAnalytics预计,在5G商用时代下,4G模组伴随着成本下降,市场的成熟,其销量将在将于2021年达到峰

    2022年9月8日
  • pl sql develop_sql中declare是什么意思

    pl sql develop_sql中declare是什么意思因为SQL只能访问、操作数据库,却不能进行程序设计,而OraclePL/SQL是一种高级数据库程序设计语言,该语言专门用于对ORACLE数据库进行访问,并且可以进行过程处理。*注:在PL/SQL中只能用SQL语句中的DML部分,不能用DDL部分,如果要在PL/SQL中使用DDL(如CREATEtable等)的话,只能以动态的方式来使用。**1.DML(datamanipulationlanguage)数据操纵语言:比如SELECT、UPDATE、INSERT、DELETE

    2022年10月12日
  • CANalyzer及CANOE使用五:无DBC,调CSV方式的网关信号转发或单通道信号值控制ECU其他信号变化(包含设计自动化测试)[通俗易懂]

    CANalyzer及CANOE使用五:无DBC,调CSV方式的网关信号转发或单通道信号值控制ECU其他信号变化(包含设计自动化测试)[通俗易懂]前言Panel界面CSV文件解析发送与接收————————————————前言同事:CAN网络UDS、NM等可以实现自动化,功能信号是否也可以?有简单方法吗?手动测太累了,矩阵表信号那么多,几十个Bit都够算了,脑袋都昏了。我:可以哇,那就整一个自动算信号bit值的吧。同事:不仅要算,还要判断ECU接收某些开关信号、温度、档位等的一系列反应(其他信号值的改变是否正确)我:可以,整一个同事:还有可能有网关转发信号起始bit,bit长度,接收的一方的信号值也要变。我:。。。。。。Pa.

    2022年6月20日
  • Linux下安装redis_redis安装部署centos

    Linux下安装redis_redis安装部署centos1、下载源代码http://code.google.com/p/redis/downloads/list下载redis-1.2.6.tar.gz将下载包拷贝到/usr/local/webserver/redis-1.2.6/下2、安装ta

    2022年10月4日
  • 拆解滴滴大脑 叶杰平谈出行领域算法技术

    拆解滴滴大脑 叶杰平谈出行领域算法技术近日,滴滴研究院副院长叶杰平在上海一场内部分享会上详细解读了滴滴大脑,这是外部首次窥探到较为完整的滴滴算法世界,并且一直潜水的产品“九霄”也首次露出真容。滴滴出行研究院副院长叶杰平滴滴大脑由三部分组成叶杰平将滴滴大脑这个智能系统分为三部分,分别是大数据、机器学习和云计算。其中大数据就像工业革命时代的煤一样举足轻重,人工智能需要数据进行训练,纵观应用级深度学习的成功案例,他们都获得了海量数据,…

    2022年5月5日

发表回复

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

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