SQL 培训 PPT

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

SQLDancyLeeSummaryTableIndexSARGStoreProcedureExecutionPlanSQL2000ArchitectureTablePrimaryKey.Alwayscreateaprimarykey.AvoidcreateprimarykeyonAttribute.NULLIndexIndexBasicClusteredIndexNon-ClusteredIndexIndexBasicAllSQLServerIndexesAreOrganizedAsB-Trees.MultipleIndexesCanBeUsedOnASingleTable.WithNoIndexes,ATableMustBeScanned.ClusteredIndexClusteredIndexDataorderbyClusteredIndexOnlyoneClusteredIndexinonetableTheleaflevelcontainsthedatapages.theclusteredkeyisduplicatedineverynon-clusteredindexrow.ClusteredIndexUniqueIfNon-Unique,RIDwillautoaddedNarrowStaticEver-increasingTheImpactofClusteredIndexChangeRecordRelocationEveryNon-ClusteredIndextobemodifiedCausepagesplitandfragmentationWasteTimeGoodClusteredIndexEver-IncreasingIdentitycolumn,IntorBigIntEver-IncreasingDatecolumnfollowedbyIdentitycolumnEver-IncreasingGUIDNon-ClusteredIndexNon-ClusteredIndexTheLeafLevelContainsaBookmark:ClusteredIndex.RID.EfficientWhenSearchingForASingleRow.95%performanceissuecanbefixedwithcorrectindex.Indexlikesalt.StoreProcedureASeriesofSQLstatements.Pre-compiled.Lownetworktraffic.SP_versusUSP_.SARG(SearchArgument)columnoperatorvalue.valueoperatorcolumn.Operatormustbeoneof=,,=,=.Somenon-SARGcanbeconverted.QueryOptimizationSELECT*versusSELECTcolumn1,column2,column3,….NeverreturnmoredatathatyoureallyneedUNIONversusUNIONALLLIKE‘%A’versusLIKE‘A%’DATEDIFF…ExecutionPlanTableScanIndexSeekClusteredIndexSeekClusteredIndexScan,aslikeTableScanPhysicaloperation:Thisistheoperatorusedbythequeryoptimizerforthisstep.Oneexamplewouldbeanestedloop.Logicaloperation:Isusuallythesameasthephysicaloperator.Whendifferent,thisrepresentsakeywordinthequery.OneexamplewouldbeINNERJOIN.Rowcount:Thisisthenumberofrowsfetchedbythisstepandpassedtothenextstep.Estimatedrowsize:Thisistheestimatedrowsizepassedontothenextstep.I/Ocost:ThisistheestimatedcostforallI/Oactivityforastep.Thelowerthisnumberisthebetter.CPUcost:ThisistheestimatedcostforallCPUactivity.Numberofexecutes:Isthenumberoftimesthestepwasexecuted.Cost:Isthecostforthestepbeingviewed.Thelowerthisnumberisthebetter.Subtreecost:Isthecostofthestepbeingviewedandallprevioussteps.SQLProfilerBooksOnline

1 / 21
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功