6、copy命令的性能参数
与copy性能相关的几个参数
arraysize 该参数用于SQL*Plus 每一次fetch数据的行数,缺省值为15,有效值是1到5000
copycommit 该参数用于copy完多少行数据之后执行commit,如果该值为0,则表示所有数据复制完毕后再执行commit
long 该参数用于设置long字符类型的最大长度,Oracle不建议使用long类型而是使用lob类型来取代
--首先设置参数arraysize与copycommit
scott@SYBO2SZ> set arraysize 15
scott@SYBO2SZ> set copycommit 0
--清空缓存
scott@SYBO2SZ> alter system flush buffer_cache;
scott@SYBO2SZ> alter system flush shared_pool;
--执行脚本调用copy创建表
scott@SYBO2SZ> @/users/robin/dba_scripts/custom/temp/cp_cmd.sql
PL/SQL procedure successfully completed.
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 5000. (long is 5000)
Table CP_BIG_TB created.
1000000 rows selected from scott@sybo2sz.
1000000 rows inserted into CP_BIG_TB.
1000000 rows committed into CP_BIG_TB at scott@sybo2sz.
PL/SQL procedure successfully completed.
The elapsed time is 41.84 seconds.
The undo size is 0
The redo size is 0
PL/SQL procedure successfully completed.
--上面得到的结果表明,copy命令被使用时不产生undo 和redo
--一百万行数据复制的时间是41.84 seconds
--下面清除刚刚复制的目的表
scott@SYBO2SZ> drop table CP_BIG_TB purge;
--清空缓存
scott@SYBO2SZ> alter system flush buffer_cache;
scott@SYBO2SZ> alter system flush shared_pool;
--设置新的arraysize与copycommit
scott@SYBO2SZ> set arraysize 2000
scott@SYBO2SZ> set copycommit 5000
--再次调用脚本
scott@SYBO2SZ> @/users/robin/dba_scripts/custom/temp/cp_cmd.sql
PL/SQL procedure successfully completed.
Array fetch/bind size is 2000. (arraysize is 2000)
Will commit after every 5000 array binds. (copycommit is 5000)
Maximum long size is 5000. (long is 5000)
Table CP_BIG_TB created.
1000000 rows selected from scott@sybo2sz.
1000000 rows inserted into CP_BIG_TB.
1000000 rows committed into CP_BIG_TB at scott@sybo2sz.
PL/SQL procedure successfully completed.
The elapsed time is 24.65 seconds.
The undo size is 0
The redo size is 0
PL/SQL procedure successfully completed.
--从上面的结果可知,后者耗用的时间明显低于前者,节约了近一半的时间
