execution plans: what can you do with them

18
Execution Plans: What Can You Do With Them

Upload: grant-fritchey

Post on 18-Jul-2015

236 views

Category:

Software


0 download

TRANSCRIPT

Execution Plans: What Can You Do With Them

Goals

• Understand the degree to which SQL Server internals are exposed through execution plans

• Learn methods for reading execution plans to expand your knowledge

• Understand ways in which you can apply this information in your own code

Why Execution Plans?

• Optimizer

• Code use

• Object use

• And then?

SELECT/INSERT/UPDATE/DELETE

• The standard

• Query tuning

• Object use

Views

• Regular view

• Materialized/indexed view• NOEXPAND

• EXPAND

• Simplification

Foreign Key

• Enforced referential integrity

• Trusted/untrusted

Calculated Column

• Zero or low cost

• Deferred execution

• Hidden costs

• Constant folding

Constraint

• INSERT

• SELECT

• Trust

Merge

• All the things

• Single execution plan

• Low to zero tuning opportunities

Triggers

• Hidden behavior

• Private execution plans

• No estimated plans

Identity

• Constant Scan

• Assert

• Gaps

User Defined Functions

• Multi-statement table valued user defined functions• AKA: Pure Evil!

• Scalar functions

• Inline table functions• AKA: parameterized views

In-Memory Stored Procedures

• 1.0

• It will change

Live Execution Plan

• Unclear purpose

• Only long running queries

• Still wicked cool

Conclusion

• It’s not just about query tuning

• You can actually see functionality

• Observation leads to knowledge

• Still just a representation

Get in touch

scarydba.com

[email protected]

@gfritchey

Grant Fritchey