《數(shù)據(jù)庫(kù)系統(tǒng)》教學(xué)課件
數(shù)據(jù)庫(kù)系統(tǒng)教學(xué)課件,數(shù)據(jù)庫(kù)系統(tǒng),數(shù)據(jù)庫(kù),系統(tǒng),教學(xué),課件
Physical DB DesignJianlin FengSchool of SoftwareSUN YAT-SEN UNIVERSITYcourtesy of Joe Hellerstein for some slidesPhysical DB DesignnQuery optimizer does what it can to use indices,clustering etc.nDataBase Administrator(DBA)is expected to set up physical design well.nGood DBAs understand query optimizers very well.One Key Decision:IndexesnWhich tablesnWhich field(s)should be the search key?nMultiple indexes?nClustering?Index SelectionnOne approach:qConsider most important queries in turn.qConsider best plan using the current indexesqSee if better plan is possible with an additional index.qIf so,create it.nBut consider impact on updates!qIndexes can make queries go faster,updates slower.qRequire disk space,too.Issues to Consider in Index SelectionnAttributes mentioned in a WHERE clause are candidates for index search keys.qRange conditions are sensitive to clustering qExact match conditions dont require clusteringnOr do they?:-)nChoose indexes that benefit many queries nNOTE:only one index can be clustered per relation!qSo choose it wisely!Example 1nB+tree index on D.dname supports Toy selection.qGiven this,index on D.dno is not needed.nB+tree on E.dno allows us to get matching(inner)Emp tuples for each selected(outer)Dept tuple.nWhat if WHERE included:.AND E.age=25?qCould retrieve Emp tuples using index on E.age,then join with Dept tuples satisfying dname selection.nComparable to strategy that used E.dno index.qSo,if E.age index is already created,this query provides much less motivation for adding an E.dno index.SELECT E.ename,D.mgrFROM Emp E,Dept DWHERE E.dno=D.dno AND D.dname=ToyExample 2nAll selections are on Emp so it should be the outer relation in any Index NL join.qSuggests that we build a B+tree index on D.dno.nWhat index should we build on Emp?qB+tree on E.sal could be used,OR an index on E.hobby could be used.qOnly one of these is needed,and which is better depends upon the selectivity of the conditions.nAs a rule of thumb,equality selections more selective than range selections.nHave to understand optimizers to get this right!SELECT E.ename,D.mgrFROM Emp E,Dept DWHERE E.sal BETWEEN 10000 AND 20000 AND E.hobby=Stamps AND E.dno=D.dnoExamples of ClusteringnB+tree index on E.age can be used to get qualifying tuples.qHow selective is the condition?qIs the index clustered?nConsider the GROUP BY query.qIf many tuples have E.age 10,using E.age index and sorting the retrieved tuples may be costly.qClustered E.dno index may be better!nEquality queries and duplicates:qClustering on E.hobby helps!SELECT E.dnoFROM Emp EWHERE E.age40SELECT E.dno,COUNT(*)FROM Emp EWHERE E.age10GROUP BY E.dnoSELECT E.dnoFROM Emp EWHERE E.hobby=Stamps
收藏
編號(hào):48634128
類型:共享資源
大?。?span id="yko2woo" class="font-tahoma">6.17MB
格式:ZIP
上傳時(shí)間:2022-01-12
30
積分
- 關(guān) 鍵 詞:
-
數(shù)據(jù)庫(kù)系統(tǒng)
數(shù)據(jù)庫(kù)
系統(tǒng)
教學(xué)
課件
- 資源描述:
-
《數(shù)據(jù)庫(kù)系統(tǒng)》教學(xué)課件,數(shù)據(jù)庫(kù)系統(tǒng),數(shù)據(jù)庫(kù),系統(tǒng),教學(xué),課件
展開(kāi)閱讀全文
- 溫馨提示:
1: 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
裝配圖網(wǎng)所有資源均是用戶自行上傳分享,僅供網(wǎng)友學(xué)習(xí)交流,未經(jīng)上傳用戶書面授權(quán),請(qǐng)勿作他用。