Oracle數(shù)據(jù)如何獲取方式進(jìn)行測試
以下的文章主要是對Oracle數(shù)據(jù)的獲取方式的相關(guān)測試,我們首先是建立相關(guān)的實(shí)驗(yàn)環(huán)境,以下就是其相關(guān)的實(shí)驗(yàn)環(huán)境的示例,如果你想對Oracle數(shù)據(jù)的獲取方式的測試有更好的了解的話,你不妨瀏覽以下的文章。
- create table test as select * from dba_objects where 0=1;
- create index ind_test_id on test(object_id);
- insert into test select * from dba_objects
- where object_id is not null and object_id>10000 order by object_id desc;
- analyze table test compute statistics for table for all columns for all indexes;
- Table Access Full
- SQL> set autotrace trace;
- SQL> select object_id from test;
- set autotrace trace;
- select object_id from test;
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- 1 | TABLE ACCESS FULL| TEST | 58650 | 229K | 239 (1)| 00:00:03 |
注意這是因?yàn)閛bject_id列默認(rèn)是可以為null的,如果修改成not null那么獲取方式會變成什么方式?
- Index Fast Full Scan
- alter table test modify(object_id not null);
- select object_id from test;
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- 1 | INDEX FAST FULL SCAN| IND_TEST_ID | 58650 | 229K| 66 (0)| 00:00:01 |
- Index Full Scan
- select/*+ index(test ind_TEST_ID)*/ object_id from test;
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- 1 | INDEX FULL SCAN| IND_TEST_ID | 58650 | 229K| 240 (1)| 00:00:03 |
- Index Range Scan
- select/*+ index(test ind_TEST_ID)*/ object_id from test where object_id < 68926;
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- 1 | INDEX RANGE SCAN| IND_TEST_ID | 57903 | 226K| 237 (1)| 00:00:03
- SQL> select object_id from test where rownum<11; INDEX FAST FULL SCAN
- OBJECT_ID
- 68917
- 68918
- 68919
- 68920
- 68921
- 68922
- 68923
- 68924
- 68925
- 68926
已選擇10行。
- SQL> select/*+ index(test ind_TEST_ID)*/ object_id from test where rownum<11; INDEX FULL SCAN
- OBJECT_ID
- 10001
- 10002
- 10003
- 10004
- 10005
- 10006
- 10007
- 10008
- 10009
- 10010
已選擇10行。
- select * from test where rownum < 2;
- ....... 69554 .......
其他的不關(guān)注只關(guān)注OBJECT_ID列 。以上的相關(guān)內(nèi)容就是對Oracle數(shù)據(jù)獲取方式測試的介紹,望你能有所收獲。
【編輯推薦】
- Oracle性能調(diào)整以及回收表空間碎片的方案
- Oracle查看和修改其最大的游標(biāo)數(shù)
- Oracle使用相關(guān)觸發(fā)器來實(shí)現(xiàn)自增ID
- Oracle使用游標(biāo)觸發(fā)器的實(shí)際存儲過程
- Oracle數(shù)據(jù)庫索引的優(yōu)點(diǎn)與缺點(diǎn)簡介