Sql Server execution plans
Upcoming SlideShare
Loading in...5
×
 

Sql Server execution plans

on

  • 558 views

 

Statistics

Views

Total Views
558
Views on SlideShare
545
Embed Views
13

Actions

Likes
0
Downloads
4
Comments
0

2 Embeds 13

https://www.linkedin.com 7
http://www.linkedin.com 6

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Startamdiscutia cu imaginea care descriearhitectura SQL Server. Din multitudinea de componente ne indreptamatentiacatre Query Engine(Processor) si Storage Engine. Pescurt, Query Engine ia in primire un statement SQL, ilparseazasi in urmaunoranalize produce ceeace se numeste Query Plan.Acest plan estetrimis (in format binar) la Storage Engine care esteresposnsabil cu accesulfizic la date. Discutia de astazi se limiteaza la Query Engine sioutputulacestuia Query Plan. Vomintelegeimpreunaceeste un Query plan, cum se poateobtine, citisiinterpreta.
  • Scopulunui Query Plan esteacela de a descoperipasiiprin care rezolva query-ulcu un consum minimum de apeluri de I/O (disk) si CPU. Cost-based plan.Serverulcreazamaimulte Query Planurisi decide pe care ilutilizeazasianumepecel cu costul minim.Serverulmentinestatisticidespredistributiasiselectivitatea (unicitatea) valorilor din coloanesiindecsi.Implicit, statisticile se mentin automat la fiecare insert, update, joinsiasamaideparte.Planulestepasatcatre Storage Engine, care ilexecuta. E posibil ca planulsa nu fie respectatde Storage Engine in cazul in care statisticile nu maisuntactuale in momentulefectiv al rularii.Planul actual siplanulestimatcelestimatestecalculatfara a rulaefectiv query-ul, cidoarpebazastatisticilorcel actual esteplanulutilizat la rularea query-uluiPlanul actual poatediferi de celestimat, in principal din doua motive: statisticilesuntincorecte (in timpelesuntalterate un urmaoperatiunilor de insert, update, delete) sau e vorba de planuri care utilizeazaparalelismsi care la momentulrulariidecid ca paraelismul nu se maipoateefectua din motive cum arfilipsamemorieisau a threadurilorlibere.Planurile de executiesunt cache-uite cu scopul de a fireutilizate. Cum crearea un pan esteO operatiecostisitoare, intr-un sistem in care se ajunge la o bunareutilizare a planurilor, se obtincastiguriconsiderabile de performanta. Exista o schema de imbatranire a planurilor deexecutiepebazacareiaplanurilesuntscoasetreptat din cache (pentru a nu se consumainutilmemorie)DBCC FREEPROCACHE – curata cache-ul, util la testare
  • Cum se vizualizeazaplanulestimatsicel actual in format Text, XML siGraficCum se automatizeazaproducerea de planurifolosind Profiler; cum se salveaza un plan XML pentru a fireutilizatmaitarziuCum se foloseste Tuning Advisor;.trc, .sql

Sql Server execution plans Sql Server execution plans Presentation Transcript

  • SQL Server 2005 – Reading and Interpreting Query Plans
    Florin Cardaşim
    Lead developer
    RomSoft, IAŞI,http://www.rms.ro
  • Agenda
    • Graphic, Xml and Text query plans
    • One-table SELECT
    • Table Join SELECT
    • INSERT, UPDATE, DELETE
  • Sql Server Architecture
    http://en.wikipedia.org/wiki/Microsoft_SQL_Server
  • Demo
    The tools:
    • Management Studio
    • Server Profiler
    • Tuning Advisor
    Execution plans representations:
    • Text (SHOWPLAN_ALL, SHOWPLAN_TEXT, STATISTICS PROFILE)
    • XML (SHOWPLAN_XML, STATISTICS XML)
    • Graphical
  • Clustered index: stores the data along with the lookup values of the index and sorts the data physically; implemented as B-tree(balanced)
    Non-clustered index: sorts the columns included in the index, but it doesn’t sorts the data
  • Q&A
  • Thank you!
    Florin Cardaşim
    Lead developer
    RomSoft, IAŞI,http://www.rms.ro