Oracle High Water Mask

High Water Mask(最高水位线,呵呵)以下简称HWM

delete命令不影响表自身的HWM,即表中的区块会随着数据量的增大而增大,但删除数据时,

区块并不会减少,当查询时,会按照HWM的标准去扫描表,即使使用delete将表数据清空,查询时,

依旧会扫描HWM的区块,查询速度也就和没使用delete命令之前是一样的,而truncate可以将表的

HWM重置。

999999条数据时,统计个数的执行计划

SQL>
  1* select count(1) from td_count

Execution Plan
---------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   SORT (AGGREGATE)
   2    1     TABLE ACCESS (FULL) OF 'TD_COUNT'

Statistics
---------------------------------------------------------
          0  recursive calls
          0  db block gets
    1004140  consistent gets
      10008  physical reads
     107380  redo size
        380  bytes sent via SQL*Net to client
        503  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

/************************************************************/

执行delete删除所有数据后的执行计划

SQL>
  1* select count(1) from td_count

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   SORT (AGGREGATE)
   2    1     TABLE ACCESS (FULL) OF 'TD_COUNT'

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
    2004139  consistent gets
      23703  physical reads
     107380  redo size
        380  bytes sent via SQL*Net to client
        503  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

/************************************************************/

执行truncate后的执行计划

SQL> select count(1) from td_count;

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   SORT (AGGREGATE)
   2    1     TABLE ACCESS (FULL) OF 'TD_COUNT'

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          3  consistent gets
          0  physical reads
          0  redo size
        380  bytes sent via SQL*Net to client
        503  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值