Tuning: Overview: Leccotech
Tuning: Overview: Leccotech
Rewrite SQL (Leccotech) Create Index Redefine Main memory tructure (S!" in #rac$e) Change the %$oc& Si'e Materia$i'ed (iew ) *enorma$i'ation +x,ort-Im,ort (dro, indexe ): defragment Chec& Loc& Se,arate data .y category in ,ro,er ta.$e ,ace /artition *ata.a e Redundant "rray of Inex,en ive *i & (R"I*) Redefining C$ient0Server "rchitecture %uy 1ardware
2hen to Index
Large ta.$e " fie$d that you 3uery .y fre3uent$y 4ie$d with high cardina$ity (not ex where card5 I on$y 6) Sma$$er 4ie$d and 4ixed $ength are ,referred5 (#. :Mo t *%MS automatica$$y index /7)
Indexe (*efau$t )
"nytime a /7 i created) an index i automatica$$y created5 "nytime when the ty,e of index i not ,ecificied) the ty,e of index created i a %0Tree 5
%0Tree (continued)
#ne node corre ,ond to one .$oc&-,age (minimum di & I0#)5 9on0Leaf node (n &ey ) n?A ,ointer ) Leaf09ode (contain n entrie ) where each entry ha an index and a ,ointer to a data .$oc&)5 "$ o) each node ha a ,ointer to next node5 "$$ $eave are at the ame height5
%itma, Index
%itma, indexe contain the &ey va$ue and a .itma, $i ting the va$ue of C or A (ye -no) for each row indicating whether the row contain that va$ue or not5 May .e a good o,tion for indexing fie$d that have $ow cardina$ity (o,,o ite of %0 tree )5
1a h Indexing
%0tree and %itma, index &ey are u ed to find row re3uiring I-# to ,roce index 1a h get row with a &ey .a ed a$gorithm Row are tored .a ed on a ha hed va$ue Index i'e hou$d .e &nown at index creation +xam,$e:
D create index cidx on order (cid) ha hed<
Index0#rgani'ed Ta.$e
Ta.$e data i incor,orated into the %0Tree u ing the /7 a the index5 Ta.$e data i a$way in order of /75 Many ort can .e avoided5 + ,ecia$$y u efu$ for F$oo&u,G ty,e ta.$e Index wor& .e t when there are few (and ma$$) co$umn in your ta.$e other than the /75
Query #,timi'er
" 3uery o,timi'er ,ar er your SQL-Query into a e3uence of re$ationa$ a$ge.ra o,eration ) determining an execution ,$an5 The 3uery o,timi'er figure out the .e t execution ,$an .a ed on ru$e of thum. and information ,rovided in the *ata *ictionary (Sy tem cata$og)5
Query #,timi'er
To view how the 3uery ,$an you mu t u e either set autotrace on or explain plan5 Set autotrace on i much im,$er5 +x,$ain ,$an i a $itt$e .it more efficient) .ut more com,$icated5
TABLE ACCESS FULL ( ull ta!le scan"# #rac$e wi$$ $oo& at every row in the ta.$e to find the re3ue ted information5 Thi i u ua$$y the $owe t way to acce a ta.$e5
TABLE ACCESS B$ %&'() #rac$e wi$$ u e the R#2I* method to find a row in the ta.$e5 R#2I* i a ,ecia$ co$umn detai$ing an exact #rac$e .$oc& where the row can .e found5 Thi i the fa te t way to acce a ta.$e (fa ter than any index5 Le f$exi.$e than any index)5
(*)E+ %A*,E SCA* #rac$e wi$$ earch an index for a range of va$ue 5 K ua$$y) thi even occur when a range or .etween o,eration i ,ecified .y the 3uery or when on$y the $eading co$umn in a com,o ite index are ,ecified .y the where c$au e5 Can ,erform we$$ or ,oor$y) .a ed on the i'e of the range and the fragmentation of the index5)5
(*)E+ U*(-UE SCA* #rac$e wi$$ ,erform thi o,eration when the ta.$e> ,rimary &ey or a uni3ue &ey i ,art of the where c$au e5 Thi i the mo t efficient way to earch an index5
*ESTE) L&&.S Indicate that a Ooin o,eration i occurring5 Can ,erform we$$ or ,oor$y) de,ending on ,erformance on the index and ta.$e o,eration of the individua$ ta.$e .eing Ooined5
R#2I*
S+L+CT R#2I*) P I9T# :+M/;R#2I*) P 4R#M +M/ 21+R+ +M/5+M/;9# E QLR66 4#R K/*"T+< K/*"T+ +M/ S+T +M/59"M+ E P 21+R+ R#2I* E :+M/;R#2I*<
R#2I* (cont5)
4a te t Le 4$exi.$e "re very u efu$ for removing du,$icate of row
S+L+CT ST"T+M+9T
9ot exi t in ,$ace of 9#T I9 Soin in ,$ace of +xi t "void u.0 e$ect +xi t in ,$ace of di tinct K9I#9 in ,$ace of #R on an index co$umn 21+R+ in tead of #R*+R %M