Patrick Purviance – SQL Server DBA Blog

Blogging impactful solutions for SQL Server DBAs worldwide

Author Archive

Windows 2003 SP2, the Scalable Networking Pack, and SQL Server – can be a bad combo

Friday, October 1st, 2010

Learned something new this week (and kind of the hard way). Hopefully this will help someone else out there.

This past Sunday morning, the Windows server group applied monthly Windows updates to our SQL Servers. This is a monthly process and typically no issues arise as we have them apply the updates to our development and test servers the week prior. However, this month, immediately after the updates were applied to the servers hosting our SQL instances and the servers restarted, performance between the servers (a lot of ETL processes here) became dismal. Jobs/Processes that normally would run in seconds or minutes wouldn’t finish at all. Seemed as though any SQL calls to our SQL 2005 Servers (all running Windows 2003 SP2) would just be sucked into the great SQL black hole.

We had’t had problems with these scheduled ETL processes earlier that morning, prior to the patches. But the following simple Linked Server select statement would take minutes from the affected servers and would return in less than 50ms from an unaffected server:

1
SELECT 1 FROM [LinkSvrA].[ApplDon].[dbo].[Customer] WHERE [CUST_NO_PK] = 1

Where LinkSvrA is the linked server running Windows 2003 SP2 (plus some Windows updates applied Sunday morning). The column, [CUST_NO_PK] is the only column in the Primary Key, Clustered Index. This was executed from a Windows 2008 server running SQL Server 2008 SP1.

After hours and hours of troubleshooting the performance problems, a couple of key indicators to me were pointing at network connectivity and throughput. The SQL Server wait types that were dominating the wait pools were OLEDB and ASYNC_NETWORK_IO. Ultimately indicating the provider (SQL Native Client in this case) is waiting on the network.

In the end, the case was escalated to Microsoft and it was determined that the Network Card settings on LnkSvrA were the root cause and after following the steps below, the issue was resolved.

Changing settings at TCP level are often not enough and the settings need to be disabled at the NIC driver level as well. You need to go into NCPA.cpl, then navigate to the Advanced network settings for your network card(s) and disable the “Chimney Offload” and Receive Side Scaling settings.

Steps to disable RSS, TCP Offloading (this is specific to the card but will usually look something like this):

• Open your network connection properties and click on “Configure”.

• In the advanced tab, set Large Offload to Disabled for all IP versions.

• Ensure Receive Side Scaling is Disabled.

• One additional recommendation we did not end up changing was the TCP and UDP Checksum Offload option. Having this set to Rx and Tx Enabled is working fine for us.

• Restart the server to ensure these settings take effect and retest your processes.

Take Away:
The SNP (Scalable Network Pack) features added and, by default, enabled by SP2 for Windows 2003 caused the performance of normally well performing processes to become abysmal. This has been a well known issue since the introduction of SP2 for Windows 2003 and Microsoft later released a patch to disable the SNP features due to the problems encountered by SQL Server and Exchange Server post SP2 implementation. In your Windows 2008 servers, the SNP features are disabled by default, so this shouldn’t be a problem.

SQL Server 2008 SP2 Released

Thursday, September 30th, 2010

Service Pack 2 for SQL Server 2008 has finally been released. I don’t usually jump on the SP bandwagon for a good 6 months, just to see what new bugs may be introduced, but I’ll probably be recommending this one within a month as I’m frustrated with not being able to use the Management Data Warehouse functionality in SQL 2008 due to an arithmetic overflow error in the data set collection processes required to gather the monitoring data for the MDW to work. For more background on that issue, see the two link below so I don’t have re-explain the problem:

To fix it, you could have installed SQL Server 2008 SP1 Cumulative Update 5 or higher, but since there were no other major issues we’ve been facing, I’ve been waiting for SP2 as it will be an easier sell here.

Here’s the link to the current page for SQL 2008 SP2:



And here’s the link to the list of fixes:

Microsoft SQL Server 2008 SP2 Download:

“Indexes? We don’t need no stinking indexes!”

Tuesday, September 28th, 2010

Yeah, right…..Alright, now that I’ve got your attention (or at least I better have if you’re a DBA worth your weight in any known unit of measure), below is a quick query for finding AND generating a script to create missing indexes for SQL Server 2005+. Now, this is just my version of a way to do it, and you may have opinions which you’re welcome to share if it will improve the query in some meaningful way for myself and everyone else, but I’ll throw out the normal disclaimer: You MUST review the recommended indexes and determine for yourself if they are appropriate for your database/workload. They may make sense, they may not, so TEST, TEST, TEST!

Have fun and good luck optimizing!

UPDATED! Now includes better formatting in the output to more closely mimic the missing index feature recommendation in SSMS execution plans.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SELECT  Obj.name as [Table Name]
	, (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) AS [Relative Impact]
	,  'CREATE NONCLUSTERED INDEX [IX_' + rtrim(Obj.name) + 
		CASE WHEN mid.equality_columns IS NULL THEN ''
			ELSE '_' + replace(replace(replace(replace(IsNull(mid.equality_columns, ''), ',', '_'), '[', ''), ']', ''), ' ', '') 
		END + 
		CASE WHEN mid.inequality_columns IS NULL THEN ''
			ELSE '_' + replace(replace(replace(replace(IsNull(mid.inequality_columns, ''), ',', '_'), '[', ''), ']', ''), ' ', '') 
		END + 
		'] ON [' + Sch.name + '].[' + Obj.name COLLATE DATABASE_DEFAULT + '] (' + 
		CASE WHEN mid.equality_columns IS NULL THEN '' 
			ELSE mid.equality_columns 
		END + 
		CASE WHEN (mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL) THEN ', '
			ELSE ''
		END + 
		CASE WHEN mid.inequality_columns IS NULL THEN ') '
			ELSE mid.inequality_columns + ') ' 
		END + 
        CASE WHEN mid.included_columns IS NULL THEN ') '  
		ELSE 'INCLUDE (' + mid.included_columns + ')' 
		END + ';' 
		AS [Create Index Statement]
	, mid.equality_columns as [Equality Columns]
	, mid.inequality_columns as [Inequality Columns]
	, mid.included_columns  as [Included Columns]
FROM sys.dm_db_missing_index_group_stats AS migs 
	INNER JOIN sys.dm_db_missing_index_groups AS mig ON migs.group_handle = mig.index_group_handle 
	INNER JOIN sys.dm_db_missing_index_details AS mid ON mig.index_handle = mid.index_handle AND mid.database_id = DB_ID() 
	INNER JOIN sys.objects Obj ON mid.OBJECT_ID = Obj.OBJECT_ID 
	INNER JOIN sys.schemas Sch ON Obj.schema_id = Sch.schema_id
WHERE (migs.group_handle IN 
		( 
		SELECT TOP (500) group_handle 
		FROM  sys.dm_db_missing_index_group_stats WITH (nolock) 
		ORDER BY (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) DESC))  
					AND OBJECTPROPERTY(Obj.OBJECT_ID, 'isusertable')=1 
ORDER BY 2 DESC , 3 DESC

Quick script to find Published Articles in Transactional Replication

Wednesday, September 22nd, 2010

Quick script to list out all of your published articles for Transaction and Snapshot Replication in SQL Server 2005+. This is based on the dbo.sysextendedarticlesview view which unions together the dbo.sysarticles (articles) and dbo.sysschemaarticles (schema only based articles…no data is replicated for these objects) tables.

Primarily posting here because it took me a while to track this information down and maybe it’ll get picked up by search engines and save you some time someday.

1
2
3
4
5
6
SELECT seav.artid as [Article ID], 
           seav.name as [Article Name], 
           sp.name as [Publication Name]
FROM dbo.sysextendedarticlesview seav inner join
        dbo.syspublications sp on sp.pubid = seav.pubid
ORDER BY 2

Tip of the Day – Check your TempDB data file count and sizes

Tuesday, July 20th, 2010

Have you checked your TempDB data file count and sizes?
And moreover, are you monitoring its performance?

A general rule of thumb for most DBAs, for best TempDB performance in SQL Server, you should have one TempDB data file for each processor core in your SQL Server and each of those data files should be the exact same size and Autogrowth turned off. The latter point is very important for correct and balanced use of the data files allocated to to the database in that filegroup, but the former point is kind of a generalized practice to make it easier on yourself when setting up a new SQL Server. We even once had an onsite Microsoft Server Analysis rep tell us we should allocate one data file per CPU, but experience tells me this isn’t always the best solution. You really need to monitor your TempDB utilization and determine what you need. If this wasn’t TempDB, how would you determine if you needed more data files for your user databases? You’d monitor performance, right? Looking for certain wait types, right? Sure you would.

See a fantastic write up by Paul Randal (SQL Server MVP and Microsoft Regional Director) below.

SQL Humor? Yeah…..SQL Humor!

Friday, July 16th, 2010
SQL Cartoon Humor Pic

Little Bobby Tables

Another SSWUG mention found…

Wednesday, July 14th, 2010

Seems I was quoted in another SSWUG email daily newsletter a while back. The topic of conversation for quite a few days was index fragmentation and how to handle it.

The link above may not work well for everyone as I can’t find a way to get a bookmark to take you directly to the quotation, but below is the original topic and my response quoted in the newsletter on 07/07/2010.

The Question:

Index Defragmentation – How Often Do You See the Need?
Once again, on the list servers here on SSWUG there is a solid discussion about index defragmentation and an application that sets up maintenance plans.

First, a question – please take just a minute and let me know – how often (on average, yes I realize it is variable) do you find yourself needing to defragment your indexes on your production databases?

My response:

…and here’s Patrick’s experience – “We have a variety of systems that we support (120 servers/150 instances (2000/2005/2008)) and my experience shows that for many systems we are able to simply ignore the fragmentation levels because the performance of the system is not negatively impacted enough by the fragmentation to become a squeaky wheel. That said, however, some of our largest systems (0.5TB to 0.8TB in size with tables approaching 120GB) require outages and defragmentation every 6 months to keep performance at an acceptable level. We have a custom built SProc that we run on a weekly basis on the majority of the systems that sends us an email based report on the fragmentation levels of the indexes and also has internal logic to identify what actions should be taken based on best practices (defrag/rebuild/drop & recreate). This rarely gives us any grief and I feel we’ve effectively addressed fragmentation from a performance standpoint enterprise wide.

Yes, you will likely find some heavily fragmented tables/indexes here and there, but by and large we have very few performance complaints that can be tracked down specifically to fragmentation (I feel due to the process we have and use). 9 times out of 10 it’s an I/O bottleneck or someone running a report where it shouldn’t be run.”

I got SSWUG Published ;)

Wednesday, July 14th, 2010

A recent request from the SSWUG email newsletter asked how we as DBAs approach and handle application/service consolidation on your SQL Server servers. I have a pretty strong feeling and approach to this topic and emailed my experience to SSWUG…..and to my surprise (for the 2nd time I just heard from another DBA friend of mine), I was “published” in the daily SSWUG newsletter. Even further to my surprise, my entire email reply was included in its entirety. Thanks SSWUG!!

And just in case the link doesn’t work someday, here’s the text of the originally posed topic and my response.

Original SSWUG Topic Question:

Who Shares Your Database Server?

Many small businesses and often times large businesses find it difficult to have servers deployed for a single purpose. They may be constrained by hardware and software costs, or not have the necessary skills to configure servers according to best practices.

For example, Microsoft encourages the use of integrated security for Sql Server. Best practices teach us that your Domain Controller and Sql Server should reside on different instances of Windows Server. Already we have two servers.

IIS running on Windows, or even Apache, are often best when run on a different server. This is especially true if the web server faces the Internet. In that case, you will most likely have a firewall between your web server and all your internal hardware, and therefore can’t share windows with Sql Server. Even web servers that are for internal purposes only should not share resources with your database.

Other products also compete for resources that are often used in conjunction with Sql Server. SSIS, SSAS, and SSRS all may require significant memory, disk or CPU resources. Many businesses also have Mail servers, application servers, etc.

Let’s hear from you. You live in the real world and have to balance resources with business needs on a daily basis. Why not share things like what you are currently doing, what you like about it, what you would like to change, and the factors that caused you to choose your current configuration. Don’t worry if your system doesn’t follow best practices. The goal here is to share with each other the issues we all face. Send your experience to btaylor@sswug.org

My published response

Patrick Says…

We have a decent number of dedicated SQL Server instances (hundreds) to support all of the different business applications utilized in our environment. Server sprawl and SQL Server “Silos” as they’ve been labeled by the Systems Admins, have become more prevalent over the last few years, and to accommodate, most of our web/application/support service servers are run in VMs. We also run our SSRS and SSAS installations on dedicated servers because the required resources to do what they’re intended to do without causing performance grief.

I’ve always been a firm believer that you must hold your ground on providing the most appropriate environment for your SQL Server databases to perform within if you have any chance of meeting rigid SLAs (written or not, expressed or implied), and rarely, if ever, allow any other applications that consume even remotely moderate amounts of memory to be run on my SQL Servers. I’ve seen too many departmental SQL Servers struggle to breath with IIS\Exchange on them and just don’t allow it unless there’s no other way, and I document my stance early on.

SQL Server requires certain things. CPU, Memory, Storage. I rarely run into CPU issues with todays (and even yesterday’s) processors. I rarely spec a server with less than 4GB of RAM and usually much more, but there are a ton of configuration options/needs there. The I/O subsystem usually is where I have to compromise most, but that’s a whole different conversation. But right now we’re talking about role/application consolidation, and to me it comes down to how much RAM and CPU is available for SQL Server with at least 30% overheard (with a little flexibility). If there’s anything left in a departmental/dev/test server, we’ll talk about it. If it’s production, fuggeddaboutit!

-Patrick

Check “Long Running Operations” Stored Procedure

Monday, June 7th, 2010

I threw together a SProc for returning useful information about long running operations for SQL Server 2005+ and thought I’d share it. The procedure uses the dynamic management objects, dm_exec_requests, dm_exec_connections, dm_exec_sessions, and dm_exec_sql_text to tell you how much longer you may have to wait on processes that SQL Server categorizes as “long running”. Typically I use this SP to find out how much longer a backup or a restore process is going to take. And it’s usually within a few minutes of being correct, so it’s worlds better than starting a restore on a SQL 2000 box and just telling everyone it will be done when it’s done and there’s little way to tell other than experience. ;)

Let me know what you think…

-Patrick

SQL Server Version/Build Lookup site

Thursday, June 3rd, 2010

Just posting a fantastic resource link today.  SQLSecurity.com keeps a nearly always up to date listing, complete with links to KB Articles and the MS product pages, for SQL Server Versions/Builds.  This one is my personal favorite of all the SQL Server build lookup pages online.

SQL Server Version/Build Lookup site
http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/tabid/63/Default.aspx

From the site authors:

This is a database of SQL Server versions for those of us who want to know what possible vulnerabilities may exist in unpatched SQL Server systems.  This makes it easier for those of us tasked with securing those environments to prepare the proper documentation outlining the threat.  Special thanks to Ken Klaft for helping maintain this area of the site.  With the seamingly endless stream of PSS-only releases out there this gets to be really time-consuming.

--Chip

Do you Tweet?

Thursday, May 27th, 2010

I finally broke down and decided to open a Twitter account and hope to use it professionally to share SQL Server knowledge. I don’t have enough interesting to follow yet, but I’m hopeful I can find a way to begin leveraging both the blog and the Twitter account to become more involved in the SQL Server community.  If you do begin to find my musings and tips helpful, follow me on Twitter here.

SQL Server 2008 & the SQL Server Surface Area Configuration Tool

Thursday, May 6th, 2010

SQL Server 2008 does away with the dedicated Surface Area Configuration Tool included with SQL Server 2005 in favor of leveraging a new facet within SSMS (SQL Server Management Studio) to now expose the properties necessary to make changes to options not available through the 2008 SQL Server Configuration Manager.

The new facet is called Surface Area Configuration and is accessed via SSMS by right-clicking on the instance name and choosing Facets.  You then select Surface Area Configuration from the Facet Drop-Down box and there you go.  Access to some feature options that you might have thought you lost after upgrading to 2008, but low and behold, Microsoft still has you covered!  Interestingly enough, this works as a single replacement alternative for the 2005 Surface Area Configuration Tool as it works with SQL Server 2005 instances as well (if you’re using SSMS 2008).

Make sure you dig around a little in the View Facets form as there are some more interesting nuggets hiding in there for you to discover….

SAC_Facet_Example

Wichita, KS SQL Users Group

Wednesday, April 28th, 2010

I’m hoping to either find or startup a local MS SQL Server Users Group.

I’ve not found anything to date in the Wichita Metro, so I’m looking for interest in gathering with local SQL Server DBAs for tech discussions, networking, and possibly bringing in special speakers.  If you are a DBA in the Wichita Metro area and would be interested, or know of someone who is, please drop me a line via the contact page and let me know.  I’m not sure how quickly we could pull something together, but with the right people, anything is possible.

If you’re lurking, subscribe to this posts comments (or my entire blog feeds) and I’ll try to keep the progress up to date.

Thanks for tuning in…..

Locate Startup Stored Procedures

Wednesday, April 28th, 2010

Quick check for stored procedures run at startup.  This will help you determine what stored procedures you may have set to run at startup.  I use this quite often (in modified form) to locate SQL Servers in the domain, leveraging SQL Server CMS (Centralized Management Server), running the SQL Blackbox trace.

Locate Startup SProcs:

Exec master..sp_MSforeachdb
'Select ''?'' [Database Name],
     name as [Startup Proc Name]
From [?]..sysobjects
Where type = ''p''
     and OBJECTPROPERTY(id, ''ExecIsStartup'') = 1;'

Tested to run on SQL 2000/2005/2008

Changing SQL Server Agent Jobs Owners

Tuesday, April 27th, 2010

Wrote a quick fix-it today for changing the owner of a SQL Agent Job from one login to another…..

Ever get annoyed by SQL Server Agent Jobs, whether created via a Maintenance Plan or any other method, defaulting the owner to the creator of the job?  I know I do.  The script below containing dynamic T-SQL will allow you to script out the change scripts needed to modify the jobs without the need of opening and modifying each job manually.  Big time saver!!!

Script to change job owner:

1
2
3
4
5
6
7
Select 'EXEC msdb.dbo.sp_update_job 
     @job_name = N''' + replace(name, '''', '''''' ) + ''', 
     owner_login_name = N''new_owner'''
From msdb..sysjobs
Where owner_sid = 
     (Select sid From master..syslogins 
      Where name like '%old_owner%')