今天对PCTFREE设置为5和10进行简单对比,测试过程如下:
以下是PCTFREE设置为5和10的测试过程:
1、创建PCTFREE=5的表test_5,为其插入数据;
SQL> create table test_10 as select * from test_5;
Table created
SQL> insert into test_5 select empno,ename from emp;
14 rows inserted
SQL> insert into test_5 select * from test_5;(反复操作)
14 rows inserted
SQL> select count(*) from test_5;
COUNT(*)
----------
117440512
2、创建创建PCTFREE=10的表test_10,为其插入数据;
SQL> create table test_10 as select * from test_5;
Table created
SQL> select count(*) from test_10;
COUNT(*)
----------
117440512
3、验证test_5和test_10的PCTFREE的值;
SQL> select table_name, pct_free from user_tables;
TABLE_NAME PCT_FREE
------------------------------ ----------
TEST_5 5
TEST_10 10
6 rows selected
4、测试两个表的执行计划对比;
SQL> set autotrace trace exp;
SQL> select * from test_5;
执行计划
----------------------------------------------------------
Plan hash value: 1935753316
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 117M| 1120M| 63590 (3)| 00:12:44 |
| 1 | TABLE ACCESS FULL| TEST_5 | 117M| 1120M| 63590 (3)| 00:12:44 |
----------------------------------------------------------------------------
SQL> select * from test_10;
执行计划----------------------------------------------------------Plan hash value: 1764743153-----------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |-----------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 117M| 1120M| 67441 (3)| 00:13:30 || 1 | TABLE ACCESS FULL| TEST_10 | 117M| 1120M| 67441 (3)| 00:13:30 |-----------------------------------------------------------------------------5、统计信息对比;
SQL> set autotrace trace stat;
SQL> select * from scott.test_5;
已选择117440512行。
统计信息
----------------------------------------------------------
277 recursive calls
0 db block gets
8044007 consistent gets
229181 physical reads
0 redo size
3209481971 bytes sent via SQL*Net to client
86123557 bytes received via SQL*Net from client
7829369 SQL*Net roundtrips to/from client
5 sorts (memory)
0 sorts (disk)
117440512 rows processed
SQL> set autotrace trace stat;SQL> select * from scott.test_10;已选择117440512行。统计信息----------------------------------------------------------254 recursive calls0 db block gets8055876 consistent gets242646 physical reads0 redo size
3209481971 bytes sent via SQL*Net to client
86123557 bytes received via SQL*Net from client7829369 SQL*Net roundtrips to/from client5 sorts (memory)0 sorts (disk)117440512 rows processed分析:1、从执行计划上来看,PCTFREE=5较PCTFREE=10在Cost和Time上都有一定的节约。2、从统计信息上看:recursive calls是执行过程中产生的递归调用,这里主要是查询一些数据字典,之前清除过shared_pool,所以这个值会高点;db block gets是从buffer cache中获取值,在执行前进行过清除buffer_cache,所以都为0;详细看 consistent gets和physical reads,PCTFREE=5较PCTFREE=10的块数少了:(8055876 + 242646) - (8044007 + 229181) = 25334总上所述:PCTFREE=5较PCTFREE=10在插入1120M的情况下,节约(25334*8)/1024 = 197.9M的空间,在检索时间上节约46秒,针对咱们自身基本没有update语句,产生行迁移的情况很少,这种方式适用;
2012-07-31
zhaoxiaoqiu