资源描述:
《高性能sql查询语句优化(optimization of high performance sql query)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、高性能sql查询语句优化(OptimizationofhighperformanceSQLquery)Intheguaranteeofrealizingthebasicfunction,minimizethedatabaseaccesstimes;throughthesearchparameters,reduceaccesstotablesofrows,minimizingtheresultset,soastoreducetheburdenofthenetwork;toseparateoperationtoseparateprocessing,impr
2、ovetheresponsespeedofeachtime;inthedatawindowusingSQL,trytousetheindexsetintheselectionofthefirst;thestructureofthealgorithmisassimpleaspossible;inthequery,notexcessiveuseofwildcardssuchasSELECT*FROMT1statementtouseseveralcolumnswillselectseveralcolumnssuchas:SELECTCOL1,COL2FROM
3、T1;wherepossibletrytolimitthenumberofresultsetrowssuchas:SELECTTOP300COL1.COL2,COL3FROMT1,becauseinsomecasestheuserisnotneededsomuchdata.Intheabsenceofindex,thedatabasetofindacertaindata,youmusthaveafulltablescanning,alldatatraverseonce,findouttheconditionoftherecord.Inthecaseof
4、asmallamountofdata,theremaybenoobviousdifference,butwhentheamountofdataislarge,thissituationisverybad.HowSQLstatementsareexecutedinSQLSERVER,andtheyworrythattheirwrittenSQLstatementswillbemisunderstoodbySQLSERVER.Forexample:Select*fromtable1wherename='Zhangsan'andtID>10000Andexe
5、cute:Select*fromtable1wheretID>10000andname='Zhangsan'Somepeopledonotknowmorethantwostatementexecutionefficiencyisthesame,becauseifasimplestatementhasfromthepointofview,thesetwostatementsarenotthesame,iftIDisapolymerizationindex,thenasimplylookupfrom10000aftertherecordinjustasen
6、tence;tostartfromthewholetabletofindoneofname='Zhangsan',andthenaccordingtotheconstraintconditionstID>10000toputforwardthequeryresults.Infact,suchfearsareunnecessary.ThereisaqueryanalysisoptimizerinSQLSERVER,whichcancalculatethesearchconditionsinthewhereclauseanddeterminewhichin
7、dexcanreducethesearchspaceofthetablescan,thatistosay,itcanrealizeautomaticoptimization.Althoughqueryoptimizercanautomaticallyqueryoptimizationaccordingtothewhereclause,sometimesthequeryoptimizerdoesnotqueryquicklyaccordingtoyouroriginalintention.Inthequeryanalysisphase,thequeryo
8、ptimizerlooksateachphaseofthequeryanddetermines