Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 391
Group categories:
Computers > Databases
More group info »
Recent pages and files
delete为什么会引起排序呢?    

大家过年好!我是个oracle新手,有个问题感觉想不通,请各位前辈指教,问题如下:

 

在生产库上监控到一个delete操作引起了大量磁盘排序,感觉很迷惑,在测试环境下做了个测试:

 

SQL> select tablespace_name,bytes/1024/1024 from dba_temp_files;
 
TABLESPACE_NAME                BYTES/1024/1024
------------------------------ ---------------
TEMP2                                      200
TEMP                                         2

 

SQL> alter database default temporary tablespace temp2;
 
Database altered.
 
SQL>  select count(*) from test;
 
  COUNT(*)
----------
    200000
 
SQL> select count(distinct object_id) from test;
 
COUNT(DISTINCTOBJECT_ID)
------------------------
                  200000
 
SQL> create unique index idx_test1 on test(object_id);
 
Index created.
 
SQL> alter database default temporary tablespace temp;
 
Database altered.
 
SQL> delete from test where object_id>0;
delete from test where object_id>0
            *
ERROR at line 1:
ORA-01652: unable to extend temp segment by 128 in tablespace TEMP

 

SQL> delete /*+ full(test) */ from test where object_id>0;
 
200000 rows deleted.

 

显然走索引范围扫描时需要排序,而全表扫描的情况下,是不需要排序。为什么delete时采用了索引范围扫描就需要排序呢,望各位前辈指点迷津,多谢了!


Version: 
Latest 3 messages about this page (5 total) - view full discussion
Feb 2 2009 by Tomas
why not using a 10053 to check what oracle do on this?

i also curious about this, Hi Kamus, is that sorting help for
deleting or redo/undo information generation?
Feb 1 2009 by Leyi Zhang (Kamus)
索引扫描之后回表查询数据需要排序。
--
Kamus <kamusis@gmail.com>

Oracle8i & 9i Certified DBA from China
Oracle ACE
Visit my blog for more article: http://www.dbform.com
Feb 1 2009 by sq l
就是想搞清楚为什么使用索引扫描后,就会引起排序呢?

2009/1/31 Tomas <housy.hou@gmail.com>
2 more messages »
Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google