2. The Developer and DBA Affair
• Ownership
– Database Ownership
– Server Ownership
– Code Ownership
• Functional working relationships
• SQL Server Performance vs. Database Performance
– Tuning T-SQL at the code level – Developer with DBA Assistance
– Hardware Tuning – DBA with Developer Assistance
3. My T-SQL is so bad your….
– Start here Developers
• Middle DBA/Code Review They should know the internals and performance
reasoning and make suggestions. i.e. so why is SELECT *
– End here Developers
4. My DBA is so bad your…
• Every role has an apple
• DBA roles aren’t bad ones
– Making relationships where it counts
• Hardware Upgrades
• Security Rights – VIEW SERVER STATE and VIEW DATABASE STATE
• Work Together!
5. Monitor – Talk DBA to me
• Active Monitoring
– Blocking
• Code practices resulting in blocking
• Proactive tuning
– Deadlocks
• #1 reason for deadlocking – Poor performance of T-SQL
– Timeouts
• Unhappy
– Oh how long is that query running?
• Event Notifications
• Extended Events
• Blocked Process Reports
6. Tuning - #1 Most Effective Area
Query Optimization
Processor
Parsing Algebrizer Optimizer
Tree
7. How SELECT is read
GROUP
FROM JOIN WHERE HAVING SELECT SORTS
BY
10. Think “Result Set” not like a developer
• Data is served not conditioned
• Business Rules apply to the business layer not the data
• Procedure <> Procedural
• Row based operations are for high-level languages
– Serve applications data – they do the work
– Minimize the data being sent and received
12. Preventive T-SQL
• Conversions – CONVERT_IMPLICIT
• Tempdb – Sort and spills from memory
• Sargable – Taking advantage of indexing in predicates
13. Abusive tempdb usage
• Estimation of memory results in more needs
• Statistics forcing poor Hash Joins
• Sorting large amounts of data
14. Find pre-existing badness
• Querying the Plan Cache
– DMV and DMF
• sys.dm_exec_cached_plans
• sys.dm_exec_sql_text
• sys.dm_exec_query_plan
15. Size Matters – Columns, Tables…Indexes
• Column Length and Type • Duplicates
• Overall Table Width • Overlapping
• Page Count • Too Many
• Overflow Page – All leading to transactional
performance issues
• DML suffers
• UPDATE
• DELETE
• INSERT
16. Index Analysis – Repeat after me!
• Duplicates
• Overlapping
• Too Many
– All leading to transactional
performance issues
• DML suffers
• UPDATE
• DELETE
• INSERT