DatabaseManagementSystems3ed,R.RamakrishnanandJ.Gehrke 1
OverviewofQueryEvaluation
Chapter12
DatabaseManagementSystems3ed,R.RamakrishnanandJ.Gehrke 2
OverviewofQueryEvaluation
- Plan: TreeofR.A.ops,withchoiceof alg foreachop.
Eachoperatortypicallyimplementedusinga`pull’ interface:whenanoperatoris`pulled’forthenextoutput tuples,it`pulls’onitsinputsandcomputesthem.
- Twomainissuesinqueryoptimization:
Foragivenquery,whatplansareconsidered?
- Algorithmtosearchplanspaceforcheapest(estimated)plan.
Howisthecostofaplanestimated?
- Ideally:Wanttofindbestplan.Practically:Avoid
worstplans!
- WewillstudytheSystemRapproach.
DatabaseManagementSystems3ed,R.RamakrishnanandJ.Gehrke 3
SomeCommonTechniques
- Algorithmsforevaluatingrelationaloperators
usesomesimpleideasextensively:
✂Indexing: CanuseWHEREconditionstoretrieve smallsetof tuples (selections,joins)
✂Iteration: Sometimes,fastertoscanall tuples evenif thereisanindex.(Andsometimes,wecanscanthe dataentriesinanindexinsteadofthetableitself.)
✂Partitioning: Byusingsortingorhashing,wecan partitiontheinput tuples andreplaceanexpensive
- perationbysimilaroperationsonsmallerinputs.