You Can Tune Your Own CodeSQL Saturday #33 Charlotte
Who Is Mike?10 years with SQLDBA roles of various sortsBlog: www.straightpathsql.com/Syndicated at SQLServerPediaFull Time – Principal DBA at global insurance company.“Spare” Time – Consult for SQL Administration and Performance IssuesPresident of new “Seacoast SQL” PASS Chapter
Who Are You?
“Why is this so slow?!”“It worked fine in dev!” “The results came back fine… I’m done”
What Aren’t We Covering?
“Can’t you     just make itfaster?!”http://www.flickr.com/photos/irinaslutsky/4000761728/
www.flickr.com/photos/no3rdw/170950846/
http://www.flickr.com/photos/dullhunk/359634390/www.flickr.com/photos/no3rdw/170950846/
AgendaTips For Slow Queries
The Right Mindset & Some Best Practices
Indexes & Statistics (Building Blocks)
Query Plans (Not So Scary)
SQL Profiler (Don’t tell my DBA friends..)
Put it all together and CLAP
DBAs don’t mean to be so mean**Maybe we do…, but let’s work it out
Goal 1You will leave using the concepts we discuss.
Goal 2You won’t ever say, “done” until you know your codePERFORMS
Goal 3“Can’t we all just get along??!”
Tips For Making Queries Slow
Right Mindset
Right MindsetSQL Is Declarative
Work With Sets
Watch Transaction Footprint
Join Where Necessary
Remember: Disk – Memory – Query
Smaller Sets ASAP
Work with the columns you need“Should I split this up?”“Should I use -that- view?” “How Many Reads Am I doing?”“What will happen in 1 year?”“How many rows are affected by that operation?”
How Are You Proving Your Code?Working with representative volume?
Testing various scenarios?
Before/After Testing?
Using Empirical Evidence?
Look and Feel with a Stop Watch???Indexes
What Are Indexes?Pointers To Data
B-Tree Structures
Sometimes – Hero Makers
Sometimes – FrustrationsClustered IndexesLeaf Level Is The Data
Narrower Is Better
Ever-Increasing
Order By

You Can Tune Your Own SQL Code