Tools and Tips: From Accidental to Efficient Data Warehouse Developer (SQLSaturday Portugal)
1. Tools and Tips:
From Accidental to Efficient
Data Warehouse Developer
Cathrine Wilhelmsen - SQLSaturday Lisbon 2015
2. Session description
You have probably heard about the Accidental DBA, but what about the Accidental Data
Warehouse developer? We stumbled into the world of data warehousing, learned dimensional
modeling and work with T-SQL and SSIS daily. We're masters of googling solutions to our
problems and make sure our complex ETL processes run without errors. We deliver data to
business users... but we don't deliver data as fast as we want.
You might not be able to rewrite your entire data warehouse or change your team's processes
over night, but there are many things you can do to increase your own productivity and become
a more efficient data warehouse developer.
In this session I will show you some of what I've learned and discovered that has made me
burst out "Oh wow! Why did I not know this yesterday!?" including query improvements, free
tools and scripts, SSMS features and even a couple of things I used to think were only useful for
those scary DBAs.
4. Say thank you to organizers and volunteers!
They spend their FREE time to give you this event
Because they are crazy
Because they want YOU to learn from the BEST IN
THE WORLD
31. Oh, by the way...
SELECT SUM(rows)
FROM sys.partitions
WHERE index_id IN (0, 1)
AND object_id =
OBJECT_ID('Sales');
...querying sys.partitions can be better and faster than COUNT(*)
32. Keyboard Shortcuts
Assign shortcuts
you frequently use
Remove shortcuts
you accidentally click
(no more "ooops")
msdn.microsoft.com/en-us/library/ms174205.aspx
55. SARGable queries
"The query can efficiently seek using an index to find the
correct rows searched for in WHERE or JOIN clauses"
Compare it to finding a person in a phone book
(We'll pretend we still use phone books)
56. Adama, Lee
Adama, William
Agathon, Karl
Baltar, Gaius
Dualla, Anastasia
Gaeta, Felix
Henderson, Cally
Roslin, Laura
Thrace, Kara
Tigh, Saul
Tyrol, Galen
Valerii, Sharon
SARGable queries
Find all rows where Name starts with "T"
57. Adama, Lee
Adama, William
Agathon, Karl
Baltar, Gaius
Dualla, Anastasia
Gaeta, Felix
Henderson, Cally
Roslin, Laura
Thrace, Kara
Tigh, Saul
Tyrol, Galen
Valerii, Sharon
SARGable queries
Find all rows where Name starts with "T"
58. Non-SARGable queries
"The query has to scan each row in the table to find the
correct rows searched for in WHERE or JOIN clauses"
Compare it to finding a person in a phone book
(We'll keep pretending we still use phone books)
59. Adama, Lee
Adama, William
Agathon, Karl
Baltar, Gaius
Dualla, Anastasia
Gaeta, Felix
Henderson, Cally
Roslin, Laura
Thrace, Kara
Tigh, Saul
Tyrol, Galen
Valerii, Sharon
Non-SARGable queries
Find all rows where Name contains "al"
60. Adama, Lee
Adama, William
Agathon, Karl
Baltar, Gaius
Dualla, Anastasia
Gaeta, Felix
Henderson, Cally
Roslin, Laura
Thrace, Kara
Tigh, Saul
Tyrol, Galen
Valerii, Sharon
Non-SARGable queries
Find all rows where Name contains "al"
61. WHERE Name LIKE '%al%'
WHERE Name LIKE 'T%'
WHERE LEFT(Name,1,1) = 'T'
SARGable or Non-SARGable?
62. WHERE Name LIKE '%al%'
WHERE Name LIKE 'T%'
WHERE LEFT(Name,1,1) = 'T'
SARGable or Non-SARGable?
63. WHERE CAST(EpisodeDate AS DATE) = '20050114'
WHERE CONVERT(CHAR(6), EpisodeDate, 112) = '200501'
WHERE YEAR(EpisodeDate) = 2005
WHERE EpisodeDate >= '20050101'
AND EpisodeDate < '20060101'
SARGable or Non-SARGable?
64. WHERE CAST(EpisodeDate AS DATE) = '20050114'
WHERE CONVERT(CHAR(6), EpisodeDate, 112) = '200501'
WHERE YEAR(EpisodeDate) = 2005
WHERE EpisodeDate >= '20050101'
AND EpisodeDate < '20060101'
SARGable or Non-SARGable?
65. WHERE Survivors < 40000
WHERE @Survivors BETWEEN Survivors-1000
AND Survivors+1000
WHERE Survivors BETWEEN @Survivors-1000
AND @Survivors+1000
SARGable or Non-SARGable?
66. WHERE Survivors < 40000
WHERE @Survivors BETWEEN Survivors-1000
AND Survivors+1000
WHERE Survivors BETWEEN @Survivors-1000
AND @Survivors+1000
SARGable or Non-SARGable?
93. The magic is in the
Extend Biml with C# or VB.NET code blocks
Import database structure and metadata
Loop over tables and columns
Add expressions to replace static values