SQL SERVER – Sample Long-Running Query for Demonstrations

I often travel across the world presenting on SQL Server Performance Tuning Topics. When I am not busy with Comprehensive Database Performance Health Check, I like to train IT professionals with SQL Server Performance Tuning Practical Workshop. I personally believe that I can’t reach everywhere to help with SQL Server Performance issues but if I train more people on this topic, they can virtually replicate me to solve their SQL Server issues. Today we will talk about a sample long-running query which I use for my demonstrations.

Demonstrations

Long-Running Query for Demonstrations

Quite often during the training, I demonstrate techniques to identify the long-running queries and how to troubleshoot them. Here is the query which I have built based on the WideWorldImporters database and it keeps on running on the extremely fast machine for over an hour.

USE WideWorldImporters
GO
-- Long Query
SELECT *
FROM [Sales].[InvoiceLines] il
INNER JOIN [Sales].[Invoices] i ON i.InvoiceID = il.InvoiceID
INNER JOIN [Sales].[OrderLines] ol ON ol.OrderID = i.OrderID
INNER JOIN [Sales].[Orders] o ON o.OrderID = ol.OrderID
GO

There are scenarios when I have to run the query much faster and in that case, I keep any one of them joins in the above script and remove the rest of the join.

I will be traveling to various different countries in Europe in September 2019. Here are the details of the my travel: September 2019 Training Updates – Czech Republic, Netherlands, Sweden, Denmark.

If you are interested in learning my SQL server Performance Tuning secrets, I strongly suggest that you enrole yourself in Recorded Online Classes SQL Server Performance Tuning Practical Workshop – Recorded Classes.

Let me know if you want to read about any particular topic of SQL Server Performance Tuning and I will be happy to blog about them in the future.

Here are a few additional blog posts on this topic:

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Performance, SQL Scripts, SQL Server, SQL Training
Previous Post
Listing Driver, Encryption and Auth Scheme for Every Connection
Next Post
SQL SERVER – Find All Tables Containing Specific Column Name

Related Posts

1 Comment. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.