楼主: dingjun123

[精华] 不要被网络或他人误导啊,学技术还是身体力行的好

[复制链接]
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
21#
发表于 2011-7-21 13:56 | 只看该作者
SQL> set autot trace stat;
SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.59
SQL> insert into a select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:07.80

Statistics
----------------------------------------------------------
       3787  recursive calls
      71482  db block gets
      10799  consistent gets
          5  physical reads
   73039404  redo size
        846  bytes sent via SQL*Net to client
        811  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.82
SQL> insert /*+append*/into a select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:06.41

Statistics
----------------------------------------------------------
       3803  recursive calls
      55060  db block gets
       7744  consistent gets
          5  physical reads
   57354540  redo size
        830  bytes sent via SQL*Net to client
        822  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.89

SQL>   insert /*+append*/into a nologging  select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:07.37

Statistics
----------------------------------------------------------
       3795  recursive calls
      55088  db block gets
       7745  consistent gets
          5  physical reads
   57390256  redo size
        831  bytes sent via SQL*Net to client
        835  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          3  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
22#
发表于 2011-7-21 14:11 | 只看该作者
--无论表是否logging,append都减少redo,但有索引redo会大
SQL> set autot trace stat
SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.66
SQL> alter table a nologging;

Table altered.

Elapsed: 00:00:00.14
SQL> insert /*+append*/into a nologging  select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:04.69

Statistics
----------------------------------------------------------
       3995  recursive calls
      55077  db block gets
       7777  consistent gets
          7  physical reads
   57373584  redo size
        818  bytes sent via SQL*Net to client
        833  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
         10  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.19
SQL> alter table a drop constraint ub;

Table altered.

Elapsed: 00:00:00.46
SQL> insert /*+append*/into a nologging  select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:01.72

Statistics
----------------------------------------------------------
       1843  recursive calls
       2571  db block gets
       1791  consistent gets
          2  physical reads
      68184  redo size
        823  bytes sent via SQL*Net to client
        833  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          8  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.08
SQL> insert /*+append*/into a  select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:01.57

Statistics
----------------------------------------------------------
       1694  recursive calls
       2570  db block gets
       1773  consistent gets
          2  physical reads
      68040  redo size
        823  bytes sent via SQL*Net to client
        823  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.07
SQL> alter table a logging;

Table altered.

Elapsed: 00:00:00.01
SQL> insert /*+append*/into a  select level from dual connect by level<=1E6;

1000000 rows created.

Elapsed: 00:00:01.55

Statistics
----------------------------------------------------------
       1843  recursive calls
       2569  db block gets
       1791  consistent gets
          2  physical reads
      68032  redo size
        826  bytes sent via SQL*Net to client
        823  bytes received via SQL*Net from client
          3  SQL*Net roundtrips to/from client
          8  sorts (memory)
          0  sorts (disk)
    1000000  rows processed

SQL>

使用道具 举报

回复
论坛徽章:
1088
金色在线徽章
日期:2007-04-25 04:02:08金色在线徽章
日期:2007-06-29 04:02:43金色在线徽章
日期:2007-03-11 04:02:02在线时间
日期:2007-04-11 04:01:02在线时间
日期:2007-04-12 04:01:02在线时间
日期:2007-03-07 04:01:022008版在线时间
日期:2010-05-01 00:01:152008版在线时间
日期:2011-05-01 00:01:342008版在线时间
日期:2008-06-03 11:59:43ITPUB年度最佳技术原创精华奖
日期:2013-03-22 13:18:30
23#
 楼主| 发表于 2011-7-21 14:12 | 只看该作者
原帖由 〇〇 于 2011-7-21 14:11 发表
--无论表是否logging,append都减少redo,但有索引redo会大
SQL> set autot trace stat
SQL> truncate table a;

Table truncated.

Elapsed: 00:00:00.66
SQL> alter table a nologging;

Table altered.

Elapsed: 00:00:00.14
SQL> insert /*+append*/into a nologging  select level from dual connect by level truncate table a;

Table truncated.

Elapsed: 00:00:00.19
SQL> alter table a drop constraint ub;

Table altered.

Elapsed: 00:00:00.46
SQL> insert /*+append*/into a nologging  select level from dual connect by level truncate table a;

Table truncated.

Elapsed: 00:00:00.08
SQL> insert /*+append*/into a  select level from dual connect by level truncate table a;

Table truncated.

Elapsed: 00:00:00.07
SQL> alter table a logging;

Table altered.

Elapsed: 00:00:00.01
SQL> insert /*+append*/into a  select level from dual connect by level


--无论表是否logging,append都减少redo,但有索引redo会大????????

eygle都测试过说错的了

使用道具 举报

回复
论坛徽章:
1088
金色在线徽章
日期:2007-04-25 04:02:08金色在线徽章
日期:2007-06-29 04:02:43金色在线徽章
日期:2007-03-11 04:02:02在线时间
日期:2007-04-11 04:01:02在线时间
日期:2007-04-12 04:01:02在线时间
日期:2007-03-07 04:01:022008版在线时间
日期:2010-05-01 00:01:152008版在线时间
日期:2011-05-01 00:01:342008版在线时间
日期:2008-06-03 11:59:43ITPUB年度最佳技术原创精华奖
日期:2013-03-22 13:18:30
24#
 楼主| 发表于 2011-7-21 14:13 | 只看该作者
当然这里测试redo,undo都是测试表的,没有说索引

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
25#
发表于 2011-7-21 14:17 | 只看该作者
我的非归档

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            +ARCH
Oldest online log sequence     5258
Current log sequence           5260

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
26#
发表于 2011-7-21 14:18 | 只看该作者
原帖由 dingjun123 于 2011-7-21 14:12 发表


--无论表是否logging,append都减少redo,但有索引redo会大????????

eygle都测试过说错的了

难道是set autot trace stat
输出错了?

使用道具 举报

回复
论坛徽章:
1088
金色在线徽章
日期:2007-04-25 04:02:08金色在线徽章
日期:2007-06-29 04:02:43金色在线徽章
日期:2007-03-11 04:02:02在线时间
日期:2007-04-11 04:01:02在线时间
日期:2007-04-12 04:01:02在线时间
日期:2007-03-07 04:01:022008版在线时间
日期:2010-05-01 00:01:152008版在线时间
日期:2011-05-01 00:01:342008版在线时间
日期:2008-06-03 11:59:43ITPUB年度最佳技术原创精华奖
日期:2013-03-22 13:18:30
27#
 楼主| 发表于 2011-7-21 14:35 | 只看该作者
不是的,那个额外的是维护索引产生的,我测试是测试表的

使用道具 举报

回复
论坛徽章:
8
数据库板块每日发贴之星
日期:2009-06-12 01:01:02数据库板块每日发贴之星
日期:2009-06-21 01:01:01ITPUB9周年纪念徽章
日期:2010-10-08 09:32:272010广州亚运会纪念徽章:游泳
日期:2010-11-12 16:42:092011新春纪念徽章
日期:2011-02-18 11:42:502010广州亚运会纪念徽章:三项全能
日期:2011-02-26 13:07:50咸鸭蛋
日期:2011-08-30 15:51:05ITPUB十周年纪念徽章
日期:2011-11-01 16:25:22
28#
发表于 2011-8-31 10:46 | 只看该作者
redo包含一下的重做信息:
1.回滚段头(undo segment header)
2.撤销块(undo block)
3.数据段头(data segment header)
4.数据块(data block)
测试环境:
SQL> select*From v$version where rownum<2;

BANNER
-------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     60
Current log sequence           68


create table notemp_test(id number,name char(1000) default ' ');

case1:对于永久表的DML
--insert 10000行数据
insert into notemp_test(id)select object_id from dba_objects where rownum<=10000;

select xid,used_ublk,used_urec from v$transaction;
XID               USED_UBLK  USED_UREC
----------------  ---------- ----------
0A0015000B030000     25       2500
--USED_UREC创建了2500条撤销记录(undo record)
select*From v$sesstat where statistic#=(select statistic# from v$statname
where name='redo entries')and sid=(select sid from v$mystat where rownum=1);

       SID STATISTIC#      VALUE
---------- ---------- ----------
       130        139       8392
--创建了8392个重做条目(redo entry)
commit以上的测试。
case2:对于永久表的direct load aperation
insert/*+ append */ into notemp_test select*from notemp_test where rownum<=10000;
select xid,used_ublk,used_urec from v$transaction;

XID               USED_UBLK  USED_UREC
---------------- ---------- ----------
0300090038030000          1          1
--创建一条撤销记录
select*From v$sesstat where statistic#=(select statistic# from v$statname
where name='redo entries')and sid=(select sid from v$mystat where rownum=1);
       SID STATISTIC#      VALUE
---------- ---------- ----------
       130        139        617
--创建617个redo entry,还是挺多的,可能是要对数据段头的信息创建redo

使用道具 举报

回复
论坛徽章:
4
ITPUB十周年纪念徽章
日期:2011-11-01 16:24:51灰彻蛋
日期:2011-11-07 07:32:08蛋疼蛋
日期:2011-12-26 14:19:11蛋疼蛋
日期:2012-04-07 01:24:00
29#
发表于 2011-11-22 08:46 | 只看该作者
实践出真知!

使用道具 举报

回复
论坛徽章:
0
30#
发表于 2011-11-25 21:25 | 只看该作者
建议LZ把环境变量的语言设成英文,看着中文真别扭。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表