Tải bản đầy đủ (.pdf) (2 trang)

OReilly SQL Tuning Dec 2003 ISBN 0596005733

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (230.64 KB, 2 trang )

Foreword
Duringmyyearsasadeveloper,andlaterasadatabase
administrator,theonlyperformancetuningareainwhichI
developedanyexpertiseandhadanylevelofsuccesswasthat
oftuningindividualSQLstatements.Becauseofthat
background,IwasveryinterestedwhenDanTowcametome
withhisideaforabookonSQLtuning.
TheproblemwithSQLtuning,atleastfrommyown
perspective,isthatitwasoftenreasonablyeasytopinpoint
badlyperformingSQLstatementsthatneededtobetuned,and
itwasreasonablyeasytodeterminetheexecutionplan
currentlybeingusedforthosebadlyperformingstatements,but
thencamethehardproblem:findingabetterexecutionplan,to
makeanoffendingSQLstatementexecutefaster.Manyisthe
timeI'vestaredatapoorlyperformingSQLstatement,
reviewingitspoorlyperformingexecutionplan,andwondered
justwhatIshoulddonext.Forthatmatter,wasthereevenany
roomforimprovement?Perhapstheexecutionplanthat
performedsobadlyfromauser'sperspectivewas,infact,the
bestpossibleexecutionplan.PerhapsIwaswastingmytime
tryingtoguessatabetterone.
There,Iusedthatwordguess,andthat'sattheheartofwhat
sometimesmadetuningSQLstatementsafrustratingactivity.It
allcamedowntomylookingataSQLstatementandtryingto
guessatabetterplan.Ofcourse,I'dattempttofactorinmy
experience,myintuition,andmyknowledgeofthedatabeing
queried,andI'dpullouttipsandtricksthatI'dreadaboutin
booksandmagazinearticles,butintheendI'dmakeaguess,
tryanewplan,makeaguess,tryanewplan,andsoforth.I'd
stopwhenoneoftwothingshappened:
Igotluckyandguessedaplanthatwasagood-enough




improvementovertheoldplantosatisfymyclient.
Iranoutofideas.
ItalwaysbotheredmewhenIranoutofideas,becauseInever
knewforsurewhetherthecurrentplanreallywasoptimalor
whetherIwasjusttoothick-headedtointuitabetterperformingexecutionplanthanthecurrentone.Tobehonest,I
wasalwaysprettyhardonmyself,chalkingupanyfailureto
improveaSQLstatementasapersonalinadequacy.
Dandoesn'tguess.Letmeboldfacethatandunderlineit.He
doesn'texecuteaniterativeguess-looplikeIdid,tryingone
ideaafteranotherinthehopeofstumblingacrossan
improvement.Instead,Danusesaninnovativeand
mathematicallybaseddiagrammingmethodtoderivethe
optimal,ornear-optimal,executionplanforaSQLstatement.
Thenheputsthatplanintoeffect.Andthat'sit.There'sno
guesswork,andthere'snouncertaintyastowhetherfurther
improvementispossible.
Atfirst,IwasskepticalofDan'sapproach.ButthemoreIread
hischapters,themoreIbegantoseethelogicbehindhis
method.Mathdoesn'tlie,andexperienceisagoodindicator.
Danhasover10yearsoftuningexperience,andhe'sbeenvery
successfulusingthemethoddescribedinthisbook.
TherearethreelegsthatanySQLtuningeffortneedstostand
on.YouneedtoknowhowtoidentifyabadlyperformingSQL
statement.Youthenneedtobeabletoseetheexecutionplan
usedforthatstatement.Finally,youneedtosomehowcomeup
withanimprovedplan.I'mconvincedthatDan'smethod
representsaviablethirdlegonwhichyourSQLtuningefforts
canrest.Readhisbook,applyhismethod,andsaveyourself

hoursofwonderingwhattodonext.
JonathanGennick,author,editor,OracleDBA



×