SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

The Voice of the DBA

The Game is Afoot

Today we have a guest editorial as Steve is traveling.

Recently I joined an effort to reduce the run time of a distributed process from 12 hours to less than 2 hours. As is almost always the case, we started with less than perfect information on how all the pieces worked together. Our understanding at the start was that scale out was possible and that the database portion was going to be a bottleneck. So much so that we discussed using read only instances to increase our throughput. Assumptions!

We did the first couple tests with a single database server and the service scale out in place. For me it was a ho-hum exercise, with 10-15% cpu usage on the database server. I looked at the queries and found that for each iteration there was one that was long running query, sometimes over a minute, but it also returned a fair amount of data - a million rows wasn’t unusual. I started working on the query, but based on everything else, it didn’t seem like we could get a big win without a redesign that wasn’t doable in the time available. It also didn’t seem like this query was the bottleneck. Interestingly at that point we couldn’t see anything that looked like a bottleneck - nothing was close to maxed out.

I saved off all the captured statements to a table (yes, I used Profiler) and started to look at the process more. Being able to sort and aggregate made it easy to see that as a percentage of database time, this query was by far the biggest chunk of database time, but that was only one part of the puzzle. There were other data stores involved. Was this the bottleneck? If so, how to prove it?

Luckily for us the one slow statement was a stored procedure. I changed it to return a Top 1. Doing that meant everything else would work even though we wouldn’t get the correct answer in the end. It’s a hack for sure, but a reasonable one in our scenario.

Discussion challenge: how would you do the same if it was submitted as dynamic sql?

This was an easy change to make, easy to revert, and in theory would let us iterate faster because the slowest part would be faster.

This was the bottleneck, or at least the first one, but that got us going. More importantly, we could put that problem on the list and keep going without figuring out to how fix it (though we had a couple ideas already). Continuing on was important because we still didn’t understand why weren’t getting the performance we expected on the rest of the hardware. A few more challenged assumptions later we understood the configuration options, the hardware usage, and had a list of scenarios to run to validate what we believed. That doesn’t solve the problem, but it defines the problems to solve clearly. It’s downhill from there.

The lesson? Maybe the main one is that it’s rare to figure it all out in one go. Investigate, iterate, repeat. The faster you iterate, the faster you prove or disprove what you think will make a difference. I believe that faster iterations helps you stay focused on the end goal because it’s way too easy to get bogged down in tuning something that just doesn’t matter.

While you’re thinking about it, think about this - how do you react when the problem is hard. The can’t find a place to start kind of hard, the hours and hours into it and still no progress kind of hard. Do you stress out? Blow up? Give up? Grind through? Or can you smile at a challenge worthy of you, enough to make you exclaim “Watson, the game is afoot!”?

Andy Warren from SQLServerCentral.com

Join the debate, and respond to today's editorial on the forums

ADVERTISEMENT
GDPR

How to make your SQL Server development GDPR ready

Redgate’s SQL Data Privacy Suite helps you to build a data catalog of your SQL Server estate, and put in processes to protect and monitor personal information. Find out more about how our tools help with GDPR compliance

SQL Monitor

What’s the top challenge faced by SQL Server professionals in 2018?

Learn how 626 SQL Server professionals monitor their estates in our new report on the State of SQL Server Monitoring. Discover the challenges currently facing the industry, and what is coming next.  Download your free copy of the report

Featured Contents

 

How to execute an SSIS package from the command line or a batch file

Stan Kulp from SQLServerCentral.com

An SSIS package that is executed on an ad hoc basis can be run from Business Intelligence Development Studio easily enough, but a package that is going to be run on a regular schedule is best executed through a batch file using the DTExec.exe command line utility. More »


 

Gene Kim joins Redgate to discuss The 2018 Accelerate State of DevOps Report

SQL Server Central editor Steve Jones is joined by acclaimed author and researcher Gene Kim to discuss the latest in all things DevOps. More »


 

A Presenter’s Guide to the Stack Overflow Database

Additional Articles from Brent Ozar Unlimited Blog

Brent shows you how the table joins work and points out some neat data distribution issues. More »


 

From the SQLServerCentral Blogs - The New SQL Provision Dashboard

Steve Jones from SQLServerCentral Blogs

As much as I liked the ability to quickly and easily build development and test databases with SQL Provision, I... More »


 

From the SQLServerCentral Blogs - SQLpassion Online Trainings for Fall 2018

Klaus Aschenbrenner from SQLServerCentral Blogs

(Be sure to checkout the FREE SQLpassion Performance Tuning Training Plan - you get a weekly email packed with all the... More »

Question of the Day

Today's Question (by Steve Jones):

What does DBCC OUTPUTBUFFER() return?

Think you know the answer? Click here, and find out if you are right.


We keep track of your score to give you bragging rights against your peers.
This question is worth 1 point in this category: DBCC.

We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the Contribution Center.

ADVERTISEMENT

Expert Scripting and Automation for SQL Server DBAs

Automate your workload and manage more databases and instances with greater ease and efficiency by combining metadata-driven automation with powerful tools like PowerShell and SQL Server Agent. Automate your new instance-builds and use monitoring to drive ongoing automation, with the help of an inventory database and a management data warehouse. Get your copy from Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Steve Jones):

I decide to add a computed column to one of my tables. I use this code:

 ALTER TABLE dbo.SalesOrderHeader ADD PONumber AS 'PO' + OrderKey 

I want to index this column. What happens when I run this code?

 CREATE INDEX SalesOrderHeaderIX_DPONumber ON dbo.SalesOrderHeader (PONumber)

Answer: The index is created

Explanation:

In this case, the column is not persisted, but it is deterministic, which is a requirement for an index on a computed column. Therefore it can be indexed.

Ref: CREATE INDEX - click here


» Discuss this question and answer on the forums

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2017 : SQL Server 2017 - Administration

Index Maintenance - Hello: How is it possible to get the SAME index name for the SAME table but the Index ID is different?...


SQL Server 2017 : SQL Server 2017 - Development

How do I use IFF statement in the WHERE - Hi, I have this table CREATE TABLE Test ( FirstName    VARCHAR(50) ,LastName    VARCHAR(50) ,Active    INT ,MaxBC        INT ) INSERT INTO Test (FirstName        

Convert all varchars in all tables to nvarchars - Hello Experts, I have a requirement where I need to convert all varchar datatypes in all tables of a database to...

XML Query - I have XML being passed into a stored procedure in the following format.  I'm struggling with how to shred it. [code...

Error when loading CSV file to SQL Server using SSIS. The Column Delimiter was not found - Can someone help me with loading the attached csv file database. The issue here is the CSV file has data with...

Need to modify the Update statement to include combination two new fields instead of one field.i want to write in better way in performance wise. - Need to modify the Update statement to include combination two new fields instead of one field: Current table cp_inv structure:  ID, cst1,...

Convert Varchar field - I have a Varchar field with units in inches :( that i need to convert to an integer (Unfortunately the " and...


SQL Server 2016 : SQL Server 2016 - Administration

Interesting question about NCI's when converting HEAPs to CI's - I've not run into it before because I don't create permanent tables as HEAPs to begin with.  I've also not...

Store values in one place and access them via various stored procedures - I am creating a number of stored procs for a particular category of things. These store procs will all have...


SQL Server 2016 : SQL Server 2016 - Development and T-SQL

Get list of possible number of guests for a hotel - Hi guys,     let me try to explain the problem. There is a hotel with rooms for 2, 3 and 4...

index scan where seek expected - On a SQL 2016 instance I have a large table with dozens of columns including: COLA INT COLB BIT and nonclustered index: (COLA...


SQL Server 2014 : Administration - SQL Server 2014

Could not find stored Procedure error - Hello, Using SQL Server 2014, Visual Studio 2015 and IIS 8.0.9, using Windows Authentication I'm at my wit's end with this issue...

Do you need seperate SPN entries for multiple SQL Server ports? - I added a port 48000 to SQL server configuration manager to allow SQL to respond to both 1433 and 48000...


SQL Server 2012 : SQL 2012 - General

Warm Standy DB Breaks When a Snapshot of it is Created - I have a db that is log shipped form Server A to Server B. I then take a snapshot of the...


SQL Server 2012 : SQL Server 2012 - T-SQL

Project Reporting Conundrum - I am in the middle of writing an SSRS when (surprise,surprise), the customer wants this funky addition to the end...

Code to list dates end of month dates between specific start and end date ranges - Hello, Looking to list out end of month dates between a start and an end point in specific data set.   For instance,  Id ...


SQL Server 2008 : SQL Server 2008 - General

I need to take row data from a table and create a "column" view - I have a table  tdataseg.    Partitionkey VARCHAR(255) NOTNULL,

SQL 2008 R2 64bit - Tools to analyse transaction log - Hi, We run SQL 2008 R2 64bit and take a FULL backup every night. Now we have come accros a situation...


SQL Server 2008 : SQL Server Newbies

Restoring msdb to copy jobs - Good Morning Experts, I have a SQL server A and it has 180 Agent jobs. I want to copy all these...


Career : Employers and Employees

Evolution of career from perm/consulting to freelancing? - Hi,    I am working as DBA for 17+years.   permanent -> consultant->  permanent -> consultant ...   at some point I start thinking about...

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com.
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.
This transmission is ©2018 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com