成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

oracle索引相關(guān)知識(shí)有哪些

這篇文章主要講解了“oracle索引相關(guān)知識(shí)有哪些”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“oracle索引相關(guān)知識(shí)有哪些”吧!

按需定制開發(fā)可以根據(jù)自己的需求進(jìn)行定制,網(wǎng)站制作、成都網(wǎng)站制作構(gòu)思過程中功能建設(shè)理應(yīng)排到主要部位公司網(wǎng)站制作、成都網(wǎng)站制作的運(yùn)用實(shí)際效果公司網(wǎng)站制作網(wǎng)站建立與制做的實(shí)際意義

一、什么是執(zhí)行計(jì)劃

所謂執(zhí)行計(jì)劃,就是在執(zhí)行一個(gè)SQL前,做出的一份數(shù)據(jù)庫認(rèn)為最佳的方案。好比在北京上班,是做地鐵去還是公交車亦或開車自駕等等。如果做地鐵,需要從哪兒換成之類的,... ...從各種方案中選擇一個(gè)自認(rèn)為最佳的方案。這個(gè)方案在數(shù)據(jù)庫里面即為執(zhí)行計(jì)劃。己認(rèn)為最合適的方案。

二、解析的概念

解析就是為sql生成執(zhí)行計(jì)劃的過程。解析分為軟解析和硬解析。

三、統(tǒng)計(jì)信息與動(dòng)態(tài)采樣

統(tǒng)計(jì)信息的作用就是為解析sql提供的數(shù)據(jù)支持,也就是為了更好的選擇執(zhí)行計(jì)劃。簡(jiǎn)單說就是統(tǒng)計(jì)信息反映表中數(shù)據(jù)分布的情況。

        如果統(tǒng)計(jì)信息沒有收集,數(shù)據(jù)庫在解析sql的過程中會(huì)根據(jù)一定的比例去表中采樣,采樣的結(jié)果作為sql執(zhí)行路徑所需代價(jià)的依據(jù)。這就是動(dòng)態(tài)采樣。

四、NULL這個(gè)特殊的東西

NULL是個(gè)特殊的一個(gè)存在。

        從定義上來講,NULL就是一個(gè)不確定的數(shù)據(jù)。所以無論對(duì)NULL做任何操作,結(jié)果還是NULL。

        另外,對(duì)于oracle數(shù)據(jù)庫來說,索引里面沒有null,索引里面沒有NULL會(huì)有什么影響呢?哈哈,見“索引快速全掃描”部分。

五、索引相關(guān)執(zhí)行計(jì)劃(補(bǔ)充索引選擇性的概念)

1 全表掃描(full table scan)

1) 測(cè)試數(shù)據(jù)

create table t1 as select * from dba_objects;

2)看執(zhí)行計(jì)劃

explain plan for select * from t1 where t1.object_id=19791;

select * from table(dbms_xplan.display());

3)注意動(dòng)態(tài)采樣與filter

2 索引唯一掃描(index unique scan)

1)創(chuàng)建唯一性索引

create unique index t1_objectid on t1(object_id);

2)收集統(tǒng)計(jì)信息

exec dbms_stats.gather_table_stats('ZQ','T1',cascade=>true);

3) 查看執(zhí)行計(jì)劃

explain plan for select * from t1 where t1.object_id=19791;

select * from table(dbms_xplan.display());

4)注意動(dòng)態(tài)采樣的消失與access

3 索引范圍掃描(index range scan)

1)測(cè)試數(shù)據(jù)

create table t2 as select * from dba_objects;

2) 創(chuàng)建非唯一性索引

create index t2_objectid on t2(object_id);

3) 收集統(tǒng)計(jì)信息

exec dbms_stats.gather_table_stats('ZQ','T2',cascade=>true);

4)查看執(zhí)行計(jì)劃

explain plan for select * from t2 where t2.object_id=19791;

select * from table(dbms_xplan.display());

5)查看執(zhí)行計(jì)劃

explain plan for select * from t1 where t1.object_id>131790;

select * from table(dbms_xplan.display());

4 索引快速全掃描(index fast full scan)

1) 查看執(zhí)行計(jì)劃

explain plan for select /*+index(t2 t2_objectid)*/object_id from t2 order by object_id;

select * from table(dbms_xplan.display());

            --走全表掃描

                insert into t2 select * from t2;

                commit;

insert into t2 select * from t2;

                commit;

         2) 收集統(tǒng)計(jì)信息,然后看執(zhí)行計(jì)劃

exec dbms_stats.gather_table_stats('ZQ','T1',cascade=>true); 

explain plan for select object_id from t2 order by object_id;

select * from table(dbms_xplan.display());

            --走全表掃描

3) 創(chuàng)建組合索引,并收集統(tǒng)計(jì)信息

create index t2_id_name on t2(object_id,object_name);

exec dbms_stats.gather_table_stats('ZQ','T2',cascade=>true);

explain plan for select object_id,object_name from t2;

select * from table(dbms_xplan.display());

   --走全表掃描

explain plan for select /*+index(t2,t2_id_name)*/object_id,object_name from t2;

select * from table(dbms_xplan.display());

---------------------為啥,哈哈哈哈哈哈,not null

4) object_id字段設(shè)置成not Null,走索引快速掃描

alter table t2 modify object_id not null;

explain plan for select /*+index(t2,t2_id_name)*/object_id,object_name from t2;

select * from table(dbms_xplan.display());

4) 使用count,索引全掃描

explain plan for select  count(object_id) from t2 ;

select * from table(dbms_xplan.display());

5 索引全掃描(index full scan)

1)查看執(zhí)行計(jì)劃

explain plan for select t1.object_id from t1 order by t1.object_id;

select * from table(dbms_xplan.display());

--注意索引快速全掃描無序,索引全掃描有序

感謝各位的閱讀,以上就是“oracle索引相關(guān)知識(shí)有哪些”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)oracle索引相關(guān)知識(shí)有哪些這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

分享標(biāo)題:oracle索引相關(guān)知識(shí)有哪些
文章出自:http://jinyejixie.com/article6/gpshog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、企業(yè)網(wǎng)站制作網(wǎng)頁設(shè)計(jì)公司、、軟件開發(fā)、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)
乐昌市| 罗定市| 新泰市| 四会市| 阳高县| 尤溪县| 康保县| 乌鲁木齐市| 义马市| 天水市| 东光县| 达孜县| 朝阳区| 开封市| 广南县| 沙田区| 尼勒克县| 武乡县| 延寿县| 新泰市| 吴堡县| 泽普县| 温泉县| 新竹县| 芒康县| 政和县| 德州市| 永年县| 台北市| 麟游县| 山东省| 迁安市| 壤塘县| 呼伦贝尔市| 屯留县| 巢湖市| 措勤县| 望奎县| 蒲城县| 治多县| 九江县|