SlideShare una empresa de Scribd logo
1 de 13
SQL DEBUGGING
OPRIS MONICA – DB & BI Developer
Outline
• SQL Server Debugging
• SQL Server Profiler
• Database EngineTuning Advisor
7/25/2013 2SQL Debugging
Demo: SQL Server 2012TSQL
Debugger
Enhancements:
1) Conditional Hit breakpoints
2) Hit Count
3) Breakpoint Filter
4) Breakpoint Action
5) Breakpoint Location
6) Export/Import the breakpoints to an XML file.
7/25/2013 3SQL Debugging
Keyboard shortcuts
Action Standard
Start or continue debugging ALT+F5
Stop debugging SHIFT+F5
Step into F11
Step over F10
Step out SHIFT+F11
Implement the RunTo Cursor command CTRL+F10
Display the QuickWatch dialog box CTRL+ALT+Q
Toggle breakpoint F9
Delete all breakpoints CTRL+SHIFT+F9
Display the Breakpoints window CTRL+ALT+B
Break all CTRL+ALT+BREAK
Display the Watch 1 window CTRL+ALT+W, 1
Display the Watch 2 window CTRL+ALT+W, 2
Display the Watch 3 window CTRL+ALT+W, 3
Display the Watch 4 window CTRL+ALT+W, 4
Display the Autos window CTRL+ALT+V, A
Display the Locals window CTRL+ALT+V, L
Display the Immediate window CTRL+ALT+I
Display the Call Stack window CTRL+ALT+C
Display the Threads window CTRL+ALT+H
7/25/2013 4SQL Debugging
Debugging using PRINT
Declare @isdebug = 1
IF @isdebug = 1 PRINT @yourvar
IF @debug = 1 BEGIN
PRINT 'Something' --or insert into a log table if you
need the rows of a temp table --or the results of a calculation
END
7/25/2013 5SQL Debugging
SQL Server Profiler
• Monitor the performance of an instance of SQL Server
• DebugTransact-SQL statements and stored procedures
• Identify slow-executing queries
• Troubleshoot problems in SQL Server by capturing events
on a production system and replaying on a test system
• Audit and review activity that occurred on an instance of
SQL Server
7/25/2013 6SQL Debugging
SQL Server Profiler terminology
• Events
• Data columns
• Filters
• Trace
7/25/2013 7SQL Debugging
7/25/2013 8
RPC:Completed,
SP:StmtCompleted
SQL:BatchStarting
SQL:BatchCompleted
Showplan XML
Duration
ObjectName
TextData
CPU
Reads
Writes
IntegerData
DatabaseName
ApplicationName
StartTime
EndTime
SPID
LoginName
EventSequence
BinaryData
SQL Server Profiler
SQL Debugging
• Which is worse, a query that runs once and takes 30
seconds to run or a query that runs 100 times and takes
1 second to run?
• Does a query run slowly every time?
7/25/2013 9
SQL Server Profiler
SQL Debugging
DTA using Profiler trace
7/25/2013 10
1) RPC:Completed
2) SP:StmtCompleted
3) SQL:BatchCompleted
1)TextData
2) Duration
3) SPID
4)DatabaseName
5)LoginName:
SQL Debugging
Conclusions
• SQL Debugger has limitations
• Profiler is not just for DBAs
• Use Profiler to learn how applications work
• Use Profiler to monitor live activity
• Collect only relevant data
• Be selective when applying DTA recommendations
7/25/2013 11SQL Debugging
References
• http://technet.microsoft.com/en-us/library/cc293612.aspx
• http://www.sqlservercentral.com/articles/SQL+Trace/99217/
• http://download.red-
gate.com/ebooks/SQL/Mastering_Profiler_eBook.pdf
• http://technet.microsoft.com/en-us/library/ms187929.aspx
• http://technet.microsoft.com/en-us/library/ms175047.aspx
• http://msdn.microsoft.com/en-us/library/ms173494(v=sql.105).aspx
• http://midnightdba.itbookworm.com/Video/Watch?VideoId=88
7/25/2013 12SQL Debugging
7/25/2013 13SQL Debugging
Thank you

Más contenido relacionado

La actualidad más candente

Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test toolKnoldus Inc.
 
February'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new featuresFebruary'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new featuresJosep Vall-llovera
 
Using SaltStack to orchestrate microservices in application containers at Sal...
Using SaltStack to orchestrate microservices in application containers at Sal...Using SaltStack to orchestrate microservices in application containers at Sal...
Using SaltStack to orchestrate microservices in application containers at Sal...Love Nyberg
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Tomas Doran
 
WTF is Sensu and Monitoring
WTF is Sensu and MonitoringWTF is Sensu and Monitoring
WTF is Sensu and MonitoringToby Jackson
 
Funambol Automated Tests for SyncML Clients
Funambol Automated Tests for SyncML ClientsFunambol Automated Tests for SyncML Clients
Funambol Automated Tests for SyncML ClientsFunambol
 
Introduction to tempest
Introduction to tempest Introduction to tempest
Introduction to tempest openstackindia
 
Writing Custom Saltstack Execution Modules
Writing Custom Saltstack Execution ModulesWriting Custom Saltstack Execution Modules
Writing Custom Saltstack Execution ModulesJulian Pacheco
 
Salty OPS – Saltstack Introduction
Salty OPS – Saltstack IntroductionSalty OPS – Saltstack Introduction
Salty OPS – Saltstack IntroductionWalter Liu
 
Why reactive:reactive programming spring 5
Why reactive:reactive programming spring 5Why reactive:reactive programming spring 5
Why reactive:reactive programming spring 5dnnddane
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013slandelle
 

La actualidad más candente (14)

Gatling - Stress test tool
Gatling - Stress test toolGatling - Stress test tool
Gatling - Stress test tool
 
September SDG - Lightning
September SDG - LightningSeptember SDG - Lightning
September SDG - Lightning
 
February'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new featuresFebruary'16 SDG - Spring'16 new features
February'16 SDG - Spring'16 new features
 
Using SaltStack to orchestrate microservices in application containers at Sal...
Using SaltStack to orchestrate microservices in application containers at Sal...Using SaltStack to orchestrate microservices in application containers at Sal...
Using SaltStack to orchestrate microservices in application containers at Sal...
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014
 
WTF is Sensu and Monitoring
WTF is Sensu and MonitoringWTF is Sensu and Monitoring
WTF is Sensu and Monitoring
 
Funambol Automated Tests for SyncML Clients
Funambol Automated Tests for SyncML ClientsFunambol Automated Tests for SyncML Clients
Funambol Automated Tests for SyncML Clients
 
Introduction to tempest
Introduction to tempest Introduction to tempest
Introduction to tempest
 
Writing Custom Saltstack Execution Modules
Writing Custom Saltstack Execution ModulesWriting Custom Saltstack Execution Modules
Writing Custom Saltstack Execution Modules
 
Salty OPS – Saltstack Introduction
Salty OPS – Saltstack IntroductionSalty OPS – Saltstack Introduction
Salty OPS – Saltstack Introduction
 
Why reactive:reactive programming spring 5
Why reactive:reactive programming spring 5Why reactive:reactive programming spring 5
Why reactive:reactive programming spring 5
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
 
Test eng-meetup-taki take
Test eng-meetup-taki takeTest eng-meetup-taki take
Test eng-meetup-taki take
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013
 

Similar a SQL debugging

Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql serverunclebiguns
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerKevin Kline
 
Enter the Dragon - SQL 2014 on Server Core PASS Summit 2014 Edition
Enter the Dragon -  SQL 2014 on Server Core PASS Summit 2014 EditionEnter the Dragon -  SQL 2014 on Server Core PASS Summit 2014 Edition
Enter the Dragon - SQL 2014 on Server Core PASS Summit 2014 EditionMark Broadbent
 
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)webhostingguy
 
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto Edition
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto EditionEnter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto Edition
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto EditionMark Broadbent
 
download it from here
download it from heredownload it from here
download it from herewebhostingguy
 
SQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - OverviewSQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - OverviewCadaxo GmbH
 
Database Performance Tuning| Rahul Gulab Singh
Database Performance Tuning| Rahul Gulab SinghDatabase Performance Tuning| Rahul Gulab Singh
Database Performance Tuning| Rahul Gulab SinghRahul Singh
 
SQLT XPLORE - The SQLT XPLAIN Hidden Child
SQLT XPLORE -  The SQLT XPLAIN Hidden ChildSQLT XPLORE -  The SQLT XPLAIN Hidden Child
SQLT XPLORE - The SQLT XPLAIN Hidden ChildEnkitec
 
Pssdiag and sql nexus
Pssdiag and sql nexusPssdiag and sql nexus
Pssdiag and sql nexusHarsh Chawla
 
SQLT XPLORE: The SQLT XPLAIN hidden child
SQLT XPLORE: The SQLT XPLAIN hidden childSQLT XPLORE: The SQLT XPLAIN hidden child
SQLT XPLORE: The SQLT XPLAIN hidden childCarlos Sierra
 
Discover financial presentation
Discover financial presentationDiscover financial presentation
Discover financial presentationPerfecto Mobile
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013Andrejs Vorobjovs
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Koen Van Hulle
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 

Similar a SQL debugging (20)

Profiling its okay in sql server
Profiling its okay in sql serverProfiling its okay in sql server
Profiling its okay in sql server
 
End-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL ServerEnd-to-end Troubleshooting Checklist for Microsoft SQL Server
End-to-end Troubleshooting Checklist for Microsoft SQL Server
 
Enter the Dragon - SQL 2014 on Server Core PASS Summit 2014 Edition
Enter the Dragon -  SQL 2014 on Server Core PASS Summit 2014 EditionEnter the Dragon -  SQL 2014 on Server Core PASS Summit 2014 Edition
Enter the Dragon - SQL 2014 on Server Core PASS Summit 2014 Edition
 
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
SDC - Programming the CLR in SQL Server 2005.ppt (1.51 MB)
 
Auditing Data Access in SQL Server
Auditing Data Access in SQL ServerAuditing Data Access in SQL Server
Auditing Data Access in SQL Server
 
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto Edition
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto EditionEnter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto Edition
Enter The Dragon - SQL 2014 on Server Core - SQLSaturday #341 Porto Edition
 
10053 otw
10053 otw10053 otw
10053 otw
 
download it from here
download it from heredownload it from here
download it from here
 
SQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - OverviewSQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - Overview
 
Database Performance Tuning| Rahul Gulab Singh
Database Performance Tuning| Rahul Gulab SinghDatabase Performance Tuning| Rahul Gulab Singh
Database Performance Tuning| Rahul Gulab Singh
 
Nadzor sql a
Nadzor sql aNadzor sql a
Nadzor sql a
 
SQLT XPLORE - The SQLT XPLAIN Hidden Child
SQLT XPLORE -  The SQLT XPLAIN Hidden ChildSQLT XPLORE -  The SQLT XPLAIN Hidden Child
SQLT XPLORE - The SQLT XPLAIN Hidden Child
 
Pssdiag and sql nexus
Pssdiag and sql nexusPssdiag and sql nexus
Pssdiag and sql nexus
 
Selenium Success
Selenium SuccessSelenium Success
Selenium Success
 
SQLT XPLORE: The SQLT XPLAIN hidden child
SQLT XPLORE: The SQLT XPLAIN hidden childSQLT XPLORE: The SQLT XPLAIN hidden child
SQLT XPLORE: The SQLT XPLAIN hidden child
 
Discover financial presentation
Discover financial presentationDiscover financial presentation
Discover financial presentation
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2
 
Into The Box 2018 Ortus Keynote
Into The Box 2018 Ortus KeynoteInto The Box 2018 Ortus Keynote
Into The Box 2018 Ortus Keynote
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 

Más de MoniqueO Opris

Master Data Management
Master Data ManagementMaster Data Management
Master Data ManagementMoniqueO Opris
 
Professional Portfolio
Professional PortfolioProfessional Portfolio
Professional PortfolioMoniqueO Opris
 
Backup And Recovery Planning
Backup And Recovery PlanningBackup And Recovery Planning
Backup And Recovery PlanningMoniqueO Opris
 
Object modeling in robotic perception
Object modeling in robotic perceptionObject modeling in robotic perception
Object modeling in robotic perceptionMoniqueO Opris
 

Más de MoniqueO Opris (6)

Master Data Management
Master Data ManagementMaster Data Management
Master Data Management
 
Database migration
Database migrationDatabase migration
Database migration
 
Professional Portfolio
Professional PortfolioProfessional Portfolio
Professional Portfolio
 
An Introduction To BI
An Introduction To BIAn Introduction To BI
An Introduction To BI
 
Backup And Recovery Planning
Backup And Recovery PlanningBackup And Recovery Planning
Backup And Recovery Planning
 
Object modeling in robotic perception
Object modeling in robotic perceptionObject modeling in robotic perception
Object modeling in robotic perception
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

SQL debugging

  • 1. SQL DEBUGGING OPRIS MONICA – DB & BI Developer
  • 2. Outline • SQL Server Debugging • SQL Server Profiler • Database EngineTuning Advisor 7/25/2013 2SQL Debugging
  • 3. Demo: SQL Server 2012TSQL Debugger Enhancements: 1) Conditional Hit breakpoints 2) Hit Count 3) Breakpoint Filter 4) Breakpoint Action 5) Breakpoint Location 6) Export/Import the breakpoints to an XML file. 7/25/2013 3SQL Debugging
  • 4. Keyboard shortcuts Action Standard Start or continue debugging ALT+F5 Stop debugging SHIFT+F5 Step into F11 Step over F10 Step out SHIFT+F11 Implement the RunTo Cursor command CTRL+F10 Display the QuickWatch dialog box CTRL+ALT+Q Toggle breakpoint F9 Delete all breakpoints CTRL+SHIFT+F9 Display the Breakpoints window CTRL+ALT+B Break all CTRL+ALT+BREAK Display the Watch 1 window CTRL+ALT+W, 1 Display the Watch 2 window CTRL+ALT+W, 2 Display the Watch 3 window CTRL+ALT+W, 3 Display the Watch 4 window CTRL+ALT+W, 4 Display the Autos window CTRL+ALT+V, A Display the Locals window CTRL+ALT+V, L Display the Immediate window CTRL+ALT+I Display the Call Stack window CTRL+ALT+C Display the Threads window CTRL+ALT+H 7/25/2013 4SQL Debugging
  • 5. Debugging using PRINT Declare @isdebug = 1 IF @isdebug = 1 PRINT @yourvar IF @debug = 1 BEGIN PRINT 'Something' --or insert into a log table if you need the rows of a temp table --or the results of a calculation END 7/25/2013 5SQL Debugging
  • 6. SQL Server Profiler • Monitor the performance of an instance of SQL Server • DebugTransact-SQL statements and stored procedures • Identify slow-executing queries • Troubleshoot problems in SQL Server by capturing events on a production system and replaying on a test system • Audit and review activity that occurred on an instance of SQL Server 7/25/2013 6SQL Debugging
  • 7. SQL Server Profiler terminology • Events • Data columns • Filters • Trace 7/25/2013 7SQL Debugging
  • 9. • Which is worse, a query that runs once and takes 30 seconds to run or a query that runs 100 times and takes 1 second to run? • Does a query run slowly every time? 7/25/2013 9 SQL Server Profiler SQL Debugging
  • 10. DTA using Profiler trace 7/25/2013 10 1) RPC:Completed 2) SP:StmtCompleted 3) SQL:BatchCompleted 1)TextData 2) Duration 3) SPID 4)DatabaseName 5)LoginName: SQL Debugging
  • 11. Conclusions • SQL Debugger has limitations • Profiler is not just for DBAs • Use Profiler to learn how applications work • Use Profiler to monitor live activity • Collect only relevant data • Be selective when applying DTA recommendations 7/25/2013 11SQL Debugging
  • 12. References • http://technet.microsoft.com/en-us/library/cc293612.aspx • http://www.sqlservercentral.com/articles/SQL+Trace/99217/ • http://download.red- gate.com/ebooks/SQL/Mastering_Profiler_eBook.pdf • http://technet.microsoft.com/en-us/library/ms187929.aspx • http://technet.microsoft.com/en-us/library/ms175047.aspx • http://msdn.microsoft.com/en-us/library/ms173494(v=sql.105).aspx • http://midnightdba.itbookworm.com/Video/Watch?VideoId=88 7/25/2013 12SQL Debugging

Notas del editor

  1. This presentation is for anyone who works with SQL and wants to have a better understanding over SQL Debugging, Profiling and DTA.
  2. DECLARE @var INT = 0WHILE( @var < 1000 ) BEGIN IF( @var%100 = 0 ) PRINT @var SET @var += 10 END
  3. As a good practice you need to run Profiler on a computer other than the SQL Server you are monitoring. This way, SQL Server doesn't have to compete for memory with Profiler.Profiler templates: Standard SP_Counts is used if you are interesting in identifying the top 10 most run sp in your application TSQL_Duration template is used to capture slow queries. TSQL – can be used by developers to debug client applications. TSQL_Replay - is often used for stress testing.TSQL_Grouped is used to investigate problem queries from a particular client or user. TSQL_SPs is used to analyze the statements within spTuning trace can be used as the row data to feed into the Database Engine Tuning Advisor for index optimization. You can create a template from scratch, you can modify an existing template or you can save your trace as a template. Notice that specific templates are associated with specific server types. The last option: you can schedule a trace’s stop time. Don’t use this option unless you are comfortable that your system won’t run out of space. Otherwise it is best to stick around during the trace watching the size of the trace file to ensure it doesn’t get too big. You can schedule a Profiler trace using the SQL Agent Job also and in the References section you can find more details on how to do this step by step. it’s important to select only those data columns you really need in order to minimize the amount of resources consumed by the trace. The problem is not in the mechanics of selecting events but in deciding which of the 170 Profiler events and 64 data columns that really want to select. You can run your trace on a production server otherwise on a test server and a stress test tool. Running Profiler on a production environment is not a recommended practice, as it could degrade the performance of the server or the connection can be lost and you miss important events.Running Server Side TraceUsing Profiler you are doing a ClientSideTracing, but you can also do ServerSideTracing which means running your trace as a script from SQL Management Studio. You can go to File and Export as a script. For more information about this please check the video posted in the references section.
  4. It’s important not only to identify long running queries but also to identify those queries that execute the most often. I think you would agree that the shorter query is more important on the overall performance of the system than the longer one. Generally we would expect the same T-SQL code to run in about the same amount of time each time it runs. If there are variations in Duration and also CPU time then is just a problem with server load.
  5. In order to start this tool you need to have prepared a trace that feed DTA to make optimized recommendations. You can choose to use the default tuning template or create your own template using the events and data columns from slide. In fact, if you include any other events in the trace, the DTA will just ignore them.Don’t forget to check Server Processes Trace Data checkbox to ensure that all these 3 trace events are captured. You need to pick a time of the day that is representative for your server load and run the trace for as long as possible -> say 8 hours, but if you can’t run the trace for this long due to disk space limitations or negative impact on server resources then consider taking multiple, smaller traces. On busy production servers the trace file can grow big very quickly. You will want to keep a close eye on the amount of disk space used by the trace so that you don’t accidently run out of room. If you consider your trace is not the best one taken then you need to run the analysis several times and compare the results to see if you can either accept them all or be selective. Once you implement the recommendations you need to go back and see if the indexes are really helping. One think I like to do is to compare Profiler traces taken before and after the DTA recommendations were implemented.
  6. Here are the references where you can find how to schedule a profiler trace, how to make a ServerSideTrace, and the download link for the Mastering SQL Server Profiler book where you can find all the events and data columns explained.