ITPub博客

首页 > Linux操作系统 > Linux操作系统 > maxtrans可以影响数据写入的块

maxtrans可以影响数据写入的块

原创 Linux操作系统 作者:ylw66 时间:2009-08-17 14:26:32 0 删除 编辑
今天做实验时偶尔发现的现象,maxtrans可以影响数据写入的块,
SQL> select * from v$version where rownum<2;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

所有Session都以scott/tiger登录

Session Monitor(用于建表和监控数据写入的数据块):
SQL> create table test(x int) maxtrans 2;
表已创建。

Session 1:
SQL> insert into test values(1);
已创建 1 行。

Session 2:
SQL> insert into test values(2);
已创建 1 行。

Session 3:
SQL> insert into test values(3);
已创建 1 行。

先后Commit Session 1,2,3
Session Monitor中:
SQL> @table_blocks.sql
输入 table 的值:  test
原值    4:  from &table) group by f,b
新值    4:  from test) group by f,b

         F          B   COUNT(*)
---------- ---------- ----------
         1      51426          2
         1      51427          1

(@table_blocks.sql ----查询表中的数据所在数据块的情况的
select f,b,count(*) from (
select dbms_rowid.rowid_relative_fno(rowid) f,
dbms_rowid.rowid_block_number(rowid) b
from &table) group by f,b;)
发现51426块中有2条记录,51427块上有1条记录

test的Pctfree和PctUsed参数都是默认的10和40
按正常来说51426块中应该有空间可以空闲空间插入数据的,为什么写入到51427块上,只是为了insert事务没有事务槽可用来了吗

又做了2个实验
实验一:不带maxtrans参数
Session Monitor(用于建表和监控数据写入的数据块):
SQL> drop table test;
表已丢弃。
SQL> create table test(x int);
表已创建。

Session 1:
SQL> insert into test values(1);
已创建 1 行。

Session 2:
SQL> insert into test values(2);
已创建 1 行。

Session 3:
SQL> insert into test values(3);
已创建 1 行。
再依次commit session1,2,3
再看@table_blocks.sql
SQL> @table_blocks.sql
输入 table 的值:  test
原值    4:  from &table) group by f,b
新值    4:  from test) group by f,b

         F          B   COUNT(*)
---------- ---------- ----------
         1      51426          3
所有数据都在51426块上


实验二:带maxtrans 3
create table test(x int) maxtrans 3;
使用4个session来测试,步骤同上
再看@table_blocks.sql
SQL> @table_blocks.sql
输入 table 的值:  test
原值    4:  from &table) group by f,b
新值    4:  from test) group by f,b

         F          B   COUNT(*)
---------- ---------- ----------
         1      51426          3
         1      51427          1

两个实验验证了我的想法,maxtrans能影响表中数据所写入的块,
至于为什么这样处理,需要大家讨论了
是不是Oracle发现insert时没有事务槽可用的情况,不等待直接使用别的块写入数据

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22111412/viewspace-612491/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-07-29

  • 博文量
    57
  • 访问量
    107662