Tune SQL Server Like A Boss! – by Uwe Ricken

During the preconference of SQLSaturday Holland #666,  the MCM (Microsoft Certified Master) Uwe Ricken gave the day-long session “Analyze and Tune SQL Server Like A Boss!”. It’s a popular event that is often sold out, much to Uwe’s surprise. Performance seems to be an ever popular subject, attracting both newcomers and seasoned veterans of the field. I told him that it is often a passion-subject, and also open ended: you will never know if you’ll hear a new trick, unsupported traceflag or VMware setting that can help you in your troubleshooting quest. Also, we get access to his script repository, so we can peek over his shoulder and see what he sees.

 

Uwe explains traceflag 1117 with cups of water

His presentation style is amusing, concise and well paced.

Just to share one of his scripts, based on an idea of Glenn Berry, the CPU consumption of each database and the percentage:

USE master;
GO

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
GO

WITH DB_CPU_Stats
AS
(
SELECT DatabaseID,
DB_NAME(DatabaseID) AS [Database Name],
SUM(total_worker_time) AS [CPU_Time_Ms]
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY
(
SELECT CAST(value AS INT) AS [DatabaseID]
FROM sys.dm_exec_plan_attributes(qs.plan_handle)
WHERE attribute = N’dbid’
) AS F_DB
GROUP BY DatabaseID
)

SELECT ROW_NUMBER() OVER(ORDER BY [CPU_Time_Ms] DESC) AS [CPU Rank],
[Database Name], [CPU_Time_Ms],
CAST
(
[CPU_Time_Ms] * 1.0 / SUM([CPU_Time_Ms]) OVER() * 100.0
AS DECIMAL(5, 2)
) AS [CPU Percent]
FROM DB_CPU_Stats
WHERE DatabaseID <> 32767 — ResourceDB
ORDER BY
[CPU Rank] OPTION (RECOMPILE);
GO

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
GO

 

Tune a query from 5 hours to 10 seconds

The other day I had to tune a query that has gone awry when it was put on new hardware. The old runtime was around one hour, but on the newer hardware it had dropped to 5 hours and 20  minutes. The main reason i could think of was that the new hardware was placed at our new IAAS solution, and as usual the storage engineers had designed for availability, not performance. The CrystalMark numbers were half of that of our own old hardware.

Join me at this tunings demo (level 300 +) :

click for video

Review: The Warschau ‘Join Conference’

6 March 2017: It’s the second edition of the “Central Europe premium SQL Server conference” in downtown Warschau.  Located in the “Palace of Culture and Science” – affectionately known as a ‘Stalin Cake’, the conference has one of the best places to host a conference:

“Palace of Culture and Science” – as seen from my AirBnB room

With a touch of grandeur the familiar faces ( such as Kalen Delaney, Klaus Aschenbrenner, Uwe Ricken, Grant Fritchey and others ) were showing their gigs. Well organised, good food and a great venue made it a good experience. The only drawback of these sessions was that there wasn’t any session material posted on the website, nor any recordings. This is a pity, as demo’s are much fun to replay at home and to investigate them a bit deeper. I’m afraid I would prefer SQLSaturdays because of this omission.

Website at http://join-conference.com/

 

Xevents part 1: Analysing the System Health Session

Many DBA’s still rely on Profiler, despite the fact that Profile can track 200 events while Extended Events can have almost 900. The deprecated Profiler is not developed anymore and cannot cope with the new kids on the block, such as Availability Groups and Azure.

Time to show the power of Extended Events. In this first video, we’ll see how to group and filter events, check out the deadlock graphs, check for waitsstats during stressmoment. All from the default Extended Events trace, the System Health Session.

No configuration or programming yet – just the tour of functionalities.

 Click for Video

There are 3 types of DBA’s – do you know them?

One of the first questions I have during an interview is : “What is a database administrator in your organisation?” This is often met with surprise because after all, “a DBA is a DBA. You know, the one who knows about the database software.”

There are however several types of DBA roles.  I’ll discuss in this video the different DBA types and their corresponding habitat.

  Click for video