/*+append*/ 知识点:
/*+append*/
1. append 属于direct insert。归档模式下append+table nologging会大量减少日志,
非归档模式append会大量减少日志,append方式插入只会产生很少的undo
2.综合一下吧:一是减少对空间的搜索;二是有可能减少redolog的产生。所以append方式会快很多,一般用于大数据量的处理
3. 建议不要经常使用append,这样表空间会一直在高水位上,除非你这个表只插不删
4. oracle append有什么作用?
请教一下,oracle中append是做什么用的。
insert /*+append*/ into table1 select * from table2
insert /*+append*/ into table1 select * from table2
在使用了append选项以后,insert数据会直接加到表的最后面,而不会在表的空闲块中插入数据。
使用append会增加数据插入的速度。
使用append会增加数据插入的速度。
/*+APPEND*/的作用是在表的高水位上分配空间,不再使用表的extent中的空余空间
append 属于direct insert,归档模式下append+table nologging会大量减少日志,非归档模式append会大量减少日志,append方式插入只会产生很少的undo
append 属于direct insert,归档模式下append+table nologging会大量减少日志,非归档模式append会大量减少日志,append方式插入只会产生很少的undo
(database)Not archived 模式 | |||
(table) Logging(default) | (table)nologging | ||
(insert)Option | Redo size | Option (insert) | Redo size |
None | 5,709,228(sec:5,674,836) | None | 5,715,368(sec:5675124) |
append | 35,808(second:13448) | append | 35,852(second:11796) |
不去寻 freelist 中的free block , 直接在table HWM 上面加入数据。
结论:非归档模式下,非归档模式append会大量减少日志,append方式插入只会产生很少的
undo
(database)Archived模式 | |||
(table ) Logging(default) | (table)nologging | ||
(insert)Option | Redo size | (insert)Option | Redo size |
None | 5,704,236(5674952) | None | 5,704,136(5674608) |
append | 5,745,088(5719340) | append | 35808(10032) |
结论:归档模式下append+table nologging会大量减少日志
Redo_size View:
SQL>create or replace view redo_size as select value from v$mystat my, v$statname st where my.statistic#=st.statstics# and st.name=’redo size’;
SQL> select * from redo_size;
VALUE
----------
40326064
SQL> insert /*+ append */ into t select * from dba_objects;
50530 rows created.
SQL> select * from redo_size;
VALUE
----------
40336096
SQL> select 40336096 - 40326064 from dual; //*insert前后做差运算,得出该次insert的redo size
40336096-40326064
-----------------
10032
Option example:
None: SQL>insert into t select * from dba_objects;
Append:SQL>insert /*+ append */ into t select * from dba_objects;
LOGGING/NOLOGGING:
Nologging: SQL>create table t as select * from dba_objects where 1=2;
Logging: SQL>create table t nologging as select * from dba_objects where 1=2;
查询数据库是否forcelogging:
SQL> select force_logging from v$database;//注:数据库处于forcelogging下,table 的nologging 是无效的。
FORCE_LOGG
----------
NO
查询表是否是处于nologging:
SQL> select table_name, logging from user_tables where table_name='TEST';
TABLE_NAME LOGGING
------------------------------ ---
TEST YES
这个eample实例示例:
1.非归档模式append,nologging,append+nologging 三种情况数据产生REDO的对比
PHP:
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 13
Current log sequence 15
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 13
Current log sequence 15
SQL> create table t as select * from dba_objects where 1=2;
Table created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 582728 2
---------- ---------- ----------
redo size 582728 2
SQL> insert into t select * from dba_objects;
10947 rows created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 1745704 2
---------- ---------- ----------
redo size 1745704 2
SQL> insert /*+append*/ into t select * from dba_objects;
10947 rows created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 1839872 2
---------- ---------- ----------
redo size 1839872 2
SQL> select (1745704-582728) redo1,(1839872-1745704) redo2 from dual;
REDO1 REDO2
---------- ----------
1162976 94168
---------- ----------
1162976 94168
SQL> drop table t;
Table dropped.
SQL> create table t nologging as select * from dba_objects where 1=2;
Table created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 3441836 2
---------- ---------- ----------
redo size 3441836 2
SQL> insert into t select * from dba_objects;
10947 rows created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 4660204 2
---------- ---------- ----------
redo size 4660204 2
SQL> insert /*+append*/ into t select * from dba_objects;
10947 rows created.
SQL> select name,value,class from v$sysstat where name='redo size';
NAME VALUE CLASS
---------- ---------- ----------
redo size 4667180 2
---------- ---------- ----------
redo size 4667180 2
SQL> select (4660204-3441836) redo1,(4667180-4660204) redo2 from dual;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论