1
DBM S I nt e r na l s Exe c ut i
- n
a nd Opt i m i z a t i
- n
M ay 10t h, 2004
Age nda
- Que
s t i
- ns
- n
pha s e 2
- f
t he pr
- j
e c t
- Today:
DBM S i nt e r na l s pa r t 2
- – Que
r y e xe c ut i
- n
– Que r y
- pt
i m i z a t i
- n
- Ne
xt we e k:
– Thur s day, not M onday. – M os t l y Phi l Be r ns t e i n
- n
m e t a
- da
t a m anage m e nt .
Que r y Exe c ut i
- n
Que r y c
- m pi
l e r Exe c ut i
- n
e ngi ne I nde x/ r e c
- r
d m gr . Buf f e r m a na ge r St
- r
a ge m a na ge r s t
- r
a ge Us e r / Appl i c a t i
- n
Que r y upda t e Que r y e xe c ut i
- n
pl a n Re c
- r
d, i nde x r e que s t s Pa ge c
- m m a
nds Re a d/ wr i t e pa ge s
Que r y Exe c ut i
- n
Pl a ns
Pur chase Per son
Buyer =nam e Ci t y=‘ seat t l e’ phone>’ 5430000’ buyer
( Si m pl e Nest ed Loops)
SELECT S.sname FROM Purchase P, Person Q WHERE P.buyer=Q.name AND Q.city=‘seattle’ AND Q.phone > ‘5430000’
s
Que r y Pl a n:
- l
- gi
c a l t r e e
- i
m pl e m e nt a t i
- n
c hoi c e a t e ve r y node
- s
c he dul i ng
- f
- pe
r a t i
- ns
.
( Tabl e scan) ( I ndex scan)
Som e
- per
at
- r
s ar e f r
- m
r el at i
- nal
al gebr a, and
- t
her s ( e. g. , scan, gr
- up)
ar e not .
The Le a ve s
- f
t he Pl a n: Sc a ns
- Ta
bl e s c a n:i t e r a t e t hr
- ugh
t he r e c
- r
ds
- f
t he r e l a t i
- n.
- I
nde x s c a n:go t
- t
he i nde x, f r
- m
t he r e ge t t he r e c
- r
ds i n t he f i l e ( whe n woul d t hi s be be t t e r ?)
- Sor
t e d s c a n:pr
- duc
e t he r e l a t i
- n
i n
- r
de r . I m pl e m e nt a t i
- n
de pe nds
- n
r e l a t i
- n
s i z e .
How do we c
- m bi
ne Ope r a t i
- ns
?
- The
i t e r a t
- r
m ode l .Ea c h
- pe
r a t i
- n
i s i m pl em e nt e d by 3 f unc t i
- ns
:
– Ope n: s e t s up t he da t a s t r uc t ur e s a nd pe r f
- r
m s i ni t i a l i z a t i
- ns
– Ge t Ne xt : r e t ur ns t he t he ne xt t upl e
- f
t he r e s ul t . – Cl
- s
e : e nds t he
- pe
r a t i
- ns
. Cl e a ns up t he da t a s t r uc t ur e s .
- Ena
bl e s pi pe l i ni ng!
- Cont
r a s t wi t h da t a
- dr
i ve n m a t e r i a l i z e m ode l .
- Som e
t i m e s i t ’ s t he s a m e ( e . g. , s
- r