ITPub博客

首页 > Linux操作系统 > Linux操作系统 > delete 删除数据 全表扫描还是扫描所有块的测试

delete 删除数据 全表扫描还是扫描所有块的测试

原创 Linux操作系统 作者:paulyibinyi 时间:2008-04-18 12:30:19 0 删除 编辑

SQL> select count(distinct b) from
  2  (select dbms_rowid.rowid_block_number(rowid) b from t);

COUNT(DISTINCTB)
----------------
              80

 

SQL> select object_id,object_name from t where object_id=6318;

 OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------

      6318
T2

 

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT ptimizer=CHOOSE (Cost=9 Card=1 Bytes=19)
   1    0   TABLE ACCESS (FULL) OF 'T' (Cost=9 Card=1 Bytes=19)

 


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
         80  consistent gets
          0  physical reads
          0  redo size
        443  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

SQL> delete from t where rownum<3000;    --删除3000条记录  总共6174条记录

2999 rows deleted.

sql>commit

 

SQL> select object_id,object_name from t where object_id=6318;

 OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------

      6318
T2

 

Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT ptimizer=CHOOSE (Cost=9 Card=1 Bytes=19)
   1    0   TABLE ACCESS (FULL) OF 'T' (Cost=9 Card=1 Bytes=19)

 


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
         80  consistent gets    --删除后全表扫描还是和原来一样大
          0  physical reads
          0  redo size
        443  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


SQL> alter tablespace tools read write;

Tablespace altered.

SQL> alter table t move tablespace tools;   把表t移到另外个表空间tools   重新组织块

Table altered.

SQL> select count(distinct b) from
  2  (select dbms_rowid.rowid_block_number(rowid) b from t);

COUNT(DISTINCTB)
----------------
              40


Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT ptimizer=CHOOSE
   1    0   SORT (GROUP BY)
   2    1     TABLE ACCESS (FULL) OF 'T'

 


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
         44  consistent gets   --一致性读降低
         40  physical reads
         60  redo size
        387  bytes sent via SQL*Net to client
        503  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
          1  rows processed

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7199859/viewspace-243818/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
oracle 10g ocm oracle 10g/11g/12c ocp aix 6.1 administrator,ogg expert,ITSS 技术交流群 201703254 微信公众号 paulyibin 探讨技术,开心工作 电话 13719354869 ,深入研究数据库和开始研究big data

注册时间:2007-12-11

  • 博文量
    902
  • 访问量
    6505073