http://technet.microsoft.com/en-us/library/ms174205%28v=sql.100%29.aspx
SQL DBA
Powershell
Getting Started with SQL Server Powershell - http://www.allaboutmssql.com/2013/03/getting-started-with-sql-server.html
Handling strings using Powershell commands - http://www.allaboutmssql.com/2013/03/handling-strings-using-powershell.html
Executing Powershell commands using SSIS - http://www.allaboutmssql.com/2013/03/executing-powershell-commands-using-ssis.html
Reading XML file using Powershell - http://www.allaboutmssql.com/2013/03/reading-xml-file-using-powershell.html
Handling files using Powershell - http://www.allaboutmssql.com/2013/03/handling-files-using-powershell.html
Powershell - Create Database,Table and Storedprocedure using SMO - http://www.allaboutmssql.com/2013/03/powershell-create-databasetable-and.html
Powershell Command to get status of SQL Server services - http://www.allaboutmssql.com/2013/03/powershell-command-to-get-status-of-sql.html
Using Powershell commands inside SQL Agent Jobs - http://www.allaboutmssql.com/2013/03/using-powershell-commands-inside-sql.html
Execute Powershell Commands inside StoredProcedure - http://www.allaboutmssql.com/2013/03/executing-powershell-commands-inside.html
Handling strings using Powershell commands - http://www.allaboutmssql.com/2013/03/handling-strings-using-powershell.html
Executing Powershell commands using SSIS - http://www.allaboutmssql.com/2013/03/executing-powershell-commands-using-ssis.html
Reading XML file using Powershell - http://www.allaboutmssql.com/2013/03/reading-xml-file-using-powershell.html
Handling files using Powershell - http://www.allaboutmssql.com/2013/03/handling-files-using-powershell.html
Powershell - Create Database,Table and Storedprocedure using SMO - http://www.allaboutmssql.com/2013/03/powershell-create-databasetable-and.html
Powershell Command to get status of SQL Server services - http://www.allaboutmssql.com/2013/03/powershell-command-to-get-status-of-sql.html
Using Powershell commands inside SQL Agent Jobs - http://www.allaboutmssql.com/2013/03/using-powershell-commands-inside-sql.html
Execute Powershell Commands inside StoredProcedure - http://www.allaboutmssql.com/2013/03/executing-powershell-commands-inside.html
SQL Server Reporting Services
SSRS (Matrix) - How to Repeat Headers on Each Page and Keep Headers Fixed while Scrolling
http://social.technet.microsoft.com/wiki/contents/articles/19505.ssrs-matrix-how-to-repeat-headers-on-each-page-and-keep-headers-fixed-while-scrolling.aspx
SSRS - No data message for report items
http://www.allaboutmssql.com/2013/08/ssrs-no-data-message-for-report-items.html
SSRS - How to display table after clicking on chart -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-display-table-after.html
SSRS - How to repeat headers on each page
http://social.technet.microsoft.com/wiki/contents/articles/19398.ssrs-how-to-repeat-headers-on-each-page.aspx
SSRS - How to display multiple columns (header and value) horizontally stacked in one row cell - http://social.technet.microsoft.com/wiki/contents/articles/19363.ssrs-how-to-display-multiple-columns-header-and-value-horizontally-stacked-in-one-row-cell.aspx
SSRS - How to set Column Visibility property for many columns based on Parameter value -
http://social.technet.microsoft.com/wiki/contents/articles/19333.ssrs-how-to-set-column-visibility-property-for-many-columns-based-on-parameter-value.aspx
SSRS - To group same row data with one column having varying data
- http://www.allaboutmssql.com/2013/08/ssrs-to-group-same-row-data-with-one.html
SSRS - How to add variables -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-add-variables.html
SSRS - Example for Conditional formatting -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-conditional-formatting.html
SSRS - How to add Custom Code and example for using Custom Code -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-add-custom-code-and-example.html
SSRS - Example for Tablix with Sparkline / Bar Chart / Indicator -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-tablix-with-sparkline.html
SSRS - Example for Lookup , LookUpSet and MultiLookup functions -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-lookup-lookupset-and.html
SSRS - Stacked Column (bar) Chart -
http://www.allaboutmssql.com/2013/08/ssrs-stacked-column-bar-chart.html
SSRS - Chart with two Vertical (Y) axes - Primary and secondary Vertical axes -
http://www.allaboutmssql.com/2013/08/ssrs-chart-with-two-vertical-y-axes.html
SSRS - Multiple Sparklines chart -
http://www.allaboutmssql.com/2013/08/ssrs-multiple-sparklines-chart.html
SSRS - Bar chart with line -
http://www.allaboutmssql.com/2013/08/ssrs-bar-chart-with-line.html
SSRS - How to repeat headers for each group -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-repeat-headers-for-each.html
SSRS - Multiple ways to split a string into multiple lines -
http://www.allaboutmssql.com/2013/07/ssrs-multiple-ways-to-split-string-into.html
SSRS - Multi Font Color / Multi Font Size within Single Field / Textbox
- http://www.allaboutmssql.com/2013/07/ssrs-multi-font-color-multi-font-size.html
SSRS - In Bar Charts , how to adjust the size of the bars -
http://www.allaboutmssql.com/2013/06/ssrs-in-bar-charts-how-to-adjust-size.html
SSRS - In Charts , how to sort labels on X - axis (Horizontal axis) -
http://www.allaboutmssql.com/2013/06/ssrs-in-charts-how-to-sort-labels-on-x.html
SSRS - In Charts , how to display all labels on the X-axis (Horizontal axis) -
http://www.allaboutmssql.com/2013/06/ssrs-in-charts-how-to-display-all.html
SSRS - [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: Argument 'Month' is not a valid value - http://www.allaboutmssql.com/2013/05/ssrs-rsruntimeerrorinexpression-value.html
SSRS - Examples for using report functions in expressions - http://www.allaboutmssql.com/2013/04/ssrs-examples-for-using-report.html
SQL Server Reporting Services - Example for creating report - http://www.allaboutmssql.com/2012/08/sql-server-reporting-services-example.html
SQL Server Reporting Services - Example for Subreport and Drill-down report - http://www.allaboutmssql.com/2012/09/sql-server-reporting-services-example.html
SSRS - IsNothing - Decision Function - http://www.allaboutmssql.com/2013/01/ssrs-isnothing-decision-function.html
SSRS - IsMissing - Visibility Function - http://www.allaboutmssql.com/2013/01/ssrs-ismissing-visibility-function.html
SQL Server Reporting Services - Lookup Expression http://www.allaboutmssql.com/2012/09/ssrs-lookup-expression.html
SSRS - Report Deployment - http://www.allaboutmssql.com/2013/02/ssrs-report-deployment.html
SQL Server Reporting Services - DATAFILE(rdl.data) - http://www.allaboutmssql.com/2013/03/sql-server-reporting-services.html
Passing comma separated values (SSRS - multivalued parameter) as input to the stored procedure -
http://social.technet.microsoft.com/wiki/contents/articles/17104.passing-comma-separated-values-ssrs-multivalued-parameter-as-input-to-the-stored-procedure.aspx
http://social.technet.microsoft.com/wiki/contents/articles/19505.ssrs-matrix-how-to-repeat-headers-on-each-page-and-keep-headers-fixed-while-scrolling.aspx
SSRS - No data message for report items
http://www.allaboutmssql.com/2013/08/ssrs-no-data-message-for-report-items.html
SSRS - How to display table after clicking on chart -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-display-table-after.html
SSRS - How to repeat headers on each page
http://social.technet.microsoft.com/wiki/contents/articles/19398.ssrs-how-to-repeat-headers-on-each-page.aspx
SSRS - How to display multiple columns (header and value) horizontally stacked in one row cell - http://social.technet.microsoft.com/wiki/contents/articles/19363.ssrs-how-to-display-multiple-columns-header-and-value-horizontally-stacked-in-one-row-cell.aspx
SSRS - How to set Column Visibility property for many columns based on Parameter value -
http://social.technet.microsoft.com/wiki/contents/articles/19333.ssrs-how-to-set-column-visibility-property-for-many-columns-based-on-parameter-value.aspx
SSRS - To group same row data with one column having varying data
- http://www.allaboutmssql.com/2013/08/ssrs-to-group-same-row-data-with-one.html
SSRS - How to add variables -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-add-variables.html
SSRS - Example for Conditional formatting -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-conditional-formatting.html
SSRS - How to add Custom Code and example for using Custom Code -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-add-custom-code-and-example.html
SSRS - Example for Tablix with Sparkline / Bar Chart / Indicator -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-tablix-with-sparkline.html
SSRS - Example for Lookup , LookUpSet and MultiLookup functions -
http://www.allaboutmssql.com/2013/08/ssrs-example-for-lookup-lookupset-and.html
SSRS - Stacked Column (bar) Chart -
http://www.allaboutmssql.com/2013/08/ssrs-stacked-column-bar-chart.html
SSRS - Chart with two Vertical (Y) axes - Primary and secondary Vertical axes -
http://www.allaboutmssql.com/2013/08/ssrs-chart-with-two-vertical-y-axes.html
SSRS - Multiple Sparklines chart -
http://www.allaboutmssql.com/2013/08/ssrs-multiple-sparklines-chart.html
SSRS - Bar chart with line -
http://www.allaboutmssql.com/2013/08/ssrs-bar-chart-with-line.html
SSRS - How to repeat headers for each group -
http://www.allaboutmssql.com/2013/08/ssrs-how-to-repeat-headers-for-each.html
SSRS - Multiple ways to split a string into multiple lines -
http://www.allaboutmssql.com/2013/07/ssrs-multiple-ways-to-split-string-into.html
SSRS - Multi Font Color / Multi Font Size within Single Field / Textbox
- http://www.allaboutmssql.com/2013/07/ssrs-multi-font-color-multi-font-size.html
SSRS - In Bar Charts , how to adjust the size of the bars -
http://www.allaboutmssql.com/2013/06/ssrs-in-bar-charts-how-to-adjust-size.html
SSRS - In Charts , how to sort labels on X - axis (Horizontal axis) -
http://www.allaboutmssql.com/2013/06/ssrs-in-charts-how-to-sort-labels-on-x.html
SSRS - In Charts , how to display all labels on the X-axis (Horizontal axis) -
http://www.allaboutmssql.com/2013/06/ssrs-in-charts-how-to-display-all.html
SSRS - [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox1.Paragraphs[0].TextRuns[0]’ contains an error: Argument 'Month' is not a valid value - http://www.allaboutmssql.com/2013/05/ssrs-rsruntimeerrorinexpression-value.html
SSRS - Examples for using report functions in expressions - http://www.allaboutmssql.com/2013/04/ssrs-examples-for-using-report.html
SQL Server Reporting Services - Example for creating report - http://www.allaboutmssql.com/2012/08/sql-server-reporting-services-example.html
SQL Server Reporting Services - Example for Subreport and Drill-down report - http://www.allaboutmssql.com/2012/09/sql-server-reporting-services-example.html
SSRS - IsNothing - Decision Function - http://www.allaboutmssql.com/2013/01/ssrs-isnothing-decision-function.html
SSRS - IsMissing - Visibility Function - http://www.allaboutmssql.com/2013/01/ssrs-ismissing-visibility-function.html
SQL Server Reporting Services - Lookup Expression http://www.allaboutmssql.com/2012/09/ssrs-lookup-expression.html
SSRS - Report Deployment - http://www.allaboutmssql.com/2013/02/ssrs-report-deployment.html
SQL Server Reporting Services - DATAFILE(rdl.data) - http://www.allaboutmssql.com/2013/03/sql-server-reporting-services.html
Passing comma separated values (SSRS - multivalued parameter) as input to the stored procedure -
http://social.technet.microsoft.com/wiki/contents/articles/17104.passing-comma-separated-values-ssrs-multivalued-parameter-as-input-to-the-stored-procedure.aspx
SQL Server Integration Services
SSIS - Extract filename from file path using TOKEN and TOKENCOUNT -
http://www.allaboutmssql.com/2013/08/ssis-extract-filename-from-file-path.html
SSIS - Shred data from XML file in folder into columns of a table -
http://www.allaboutmssql.com/2013/08/ssis-shred-data-from-xml-file-in-folder.html
SSIS - Capture Filenames while looping through multiple files inside folder - http://www.allaboutmssql.com/2013/02/ssis-capture-filenames-while-looping.html
SQL Server Integration services - Rename and move files from source folder to destination folder - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-rename.html
SQL Server Integration Services - Logging in Packages - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-logging.html
SQL Server Integration Services - Error handling for truncation error - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-error.html
SQL Server Integration Services - DelayValidation property - http://www.allaboutmssql.com/2012/09/sql-server-integration-services.html
SSIS - CODEPOINT Function - http://www.allaboutmssql.com/2013/01/ssis-codepoint-function.html
SSIS -Solution for mixed data types problem while importing from excel - http://www.allaboutmssql.com/2012/08/ssis-solution-for-mixed-data-types.html
SSIS - Truncation error while exporting from excel to database - http://www.allaboutmssql.com/2012/07/ssis-truncation-error-while-exporting.html
SQL Server Integration Services - Error codes,Error symbolic names and Error messages - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-error_10.html
Migrating DTS Packages to Integration Services - http://www.allaboutmssql.com/2012/04/migrating-dts-packages-to-integration.html
SQL Server Integration Services - ForceExecutionResult - http://www.allaboutmssql.com/2013/02/sql-server-integration-services.html
SSIS - Execute SQL Task - Result Set and Parameter Mapping
http://www.allaboutmssql.com/2013/04/ssis-execute-sql-task-result-set-and.html
SSIS - How to Add Missing Control Flow Items / Data Flow Items to the SSIS Toolbox
- http://www.allaboutmssql.com/2013/07/ssis-how-to-add-missing-control-flow.html
SSIS - Move Folder from one Drive to Another Drive Using File System Task
- http://www.allaboutmssql.com/2013/07/ssis-move-folder-from-one-drive-to.html
http://www.allaboutmssql.com/2013/08/ssis-extract-filename-from-file-path.html
SSIS - Shred data from XML file in folder into columns of a table -
http://www.allaboutmssql.com/2013/08/ssis-shred-data-from-xml-file-in-folder.html
SSIS - Capture Filenames while looping through multiple files inside folder - http://www.allaboutmssql.com/2013/02/ssis-capture-filenames-while-looping.html
SQL Server Integration services - Rename and move files from source folder to destination folder - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-rename.html
SQL Server Integration Services - Logging in Packages - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-logging.html
SQL Server Integration Services - Error handling for truncation error - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-error.html
SQL Server Integration Services - DelayValidation property - http://www.allaboutmssql.com/2012/09/sql-server-integration-services.html
SSIS - CODEPOINT Function - http://www.allaboutmssql.com/2013/01/ssis-codepoint-function.html
SSIS -Solution for mixed data types problem while importing from excel - http://www.allaboutmssql.com/2012/08/ssis-solution-for-mixed-data-types.html
SSIS - Truncation error while exporting from excel to database - http://www.allaboutmssql.com/2012/07/ssis-truncation-error-while-exporting.html
SQL Server Integration Services - Error codes,Error symbolic names and Error messages - http://www.allaboutmssql.com/2012/09/sql-server-integration-services-error_10.html
Migrating DTS Packages to Integration Services - http://www.allaboutmssql.com/2012/04/migrating-dts-packages-to-integration.html
SQL Server Integration Services - ForceExecutionResult - http://www.allaboutmssql.com/2013/02/sql-server-integration-services.html
SSIS - Execute SQL Task - Result Set and Parameter Mapping
http://www.allaboutmssql.com/2013/04/ssis-execute-sql-task-result-set-and.html
SSIS - How to Add Missing Control Flow Items / Data Flow Items to the SSIS Toolbox
- http://www.allaboutmssql.com/2013/07/ssis-how-to-add-missing-control-flow.html
SSIS - Move Folder from one Drive to Another Drive Using File System Task
- http://www.allaboutmssql.com/2013/07/ssis-move-folder-from-one-drive-to.html
log_reuse_wait_desc = replication, transaction log won't stop growing
SELECT name, log_reuse_wait_desc FROM sys.databases
--if the log_reuse_wait_desc is replication then remove it
EXEC sp_removedbreplication YourDatabaseName
SELECT name, log_reuse_wait_desc FROM sys.databases
-- log_reuse_wait_desc on database should be changed to "nothing" now. if yes do following steps
ALTER DATABASE YourDatabaseName SET RECOVERY SIMPLE
DBCC SHRINKFILE (N'Your Logical Log Name', 0, TRUNCATEONLY)
--Now My log file size drop from 18GB to 0MB
--after that you should reset you database recovery model to full if you need.
--if the log_reuse_wait_desc is replication then remove it
EXEC sp_removedbreplication YourDatabaseName
SELECT name, log_reuse_wait_desc FROM sys.databases
-- log_reuse_wait_desc on database should be changed to "nothing" now. if yes do following steps
ALTER DATABASE YourDatabaseName SET RECOVERY SIMPLE
DBCC SHRINKFILE (N'Your Logical Log Name', 0, TRUNCATEONLY)
--Now My log file size drop from 18GB to 0MB
--after that you should reset you database recovery model to full if you need.
Size of the Transaction Log Increasing and cannot be truncated or Shrinked due to Snapshot Replication.
There
can be many reasons for the size of Transaction Log growing large for a
sql server database such as waiting on checkpoint, backups in Full
recovery model, active long running transaction.
The
simplest and the smartest way to determine the cause of the Transaction
Log in sql server 2005 is with the use of columns log_reuse_wait,
log_reuse_wait_desc in sys.databases view in Sql Server 2005 and 2008.
So we fire the following query to find the cause of the Transaction Log growth and observe the following
select log_reuse_wait_desc,name from sys.databases
log_reuse_wait_desc name
------------------------------------------------------------ -------------
REPLICATION test
And to
our surprise the log_reuse_wait_desc column reflects REPLICATION for a
particular database which has snapshot replication configured on it.
So we
conclude the Log growth is caused due to Snapshot Replication which is
kind of ironical since Snapshot Replication does not use Transaction
logs to replicate data to the remote site.
So to
confirm this we fire the DBCC OPENTRAN which gives the undistributed LSN
for the Transaction log and we get an undistributed LSN value as shown
below
DBCC OPENTRAN(13)
Transaction information for database 'test’.
Replicated Transaction Information:
Oldest distributed LSN : (0:0:0)
Oldest non-distributed LSN : (43831:51:1)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
So this
confirms that above undistributed transaction is causing the Log
Growth. But in Snapshot Replication the changes are replicated using
Snapshots and not using Transaction Logs.
We have
a Known issue with Snapshot Replication in Sql Server 2005 which causes
DDL changes on the tables which have SCHEMA CHANGES marked for
replication where in the DDL statements are marked for Replication in
Transaction log of the database but they are not unmarked when the
changes are actually propagated.
In order to confirm whether we are hitting the issue mentioned above we need to check whether that undistributed LSN ((43831:51:1) in above case)
provided in DBCC OPENTRAN output is pointing to DDL operations of type ALTER TABLE.
The
issue is yet to be fixed and hence the workaround to avoid the issue is
to either remove the REPLICATION OF SCHEMA CHANGES for the tables
involved in the replication
Or
Use the following commands after running Snapshot Agent and applying the Snapshot on the subscriber.
sp_repldone null, null, 0,0,1
Before
running the above command we need to ensure that SCHEMA changes are
actually being replicated in order to avoid any inconsistency
Note:
This
post should not be treated as the Microsoft’s Recommendation or
Resolution to the problem, it is only a workaround which worked in our
environment and so we would like to share it.
Troubleshooting SQL Server CPU Performance Issues
In this post I’ll discuss a general methodology
for troubleshooting CPU performance issues. I like applying
methodologies by default and I also like building efficiencies in how I
troubleshoot issues based on past experiences. Without a general
framework, it becomes too easy to miss the true root cause in the middle
of a crisis.
The steps I’ll describe in this post are as follows:- Define the problem
- Validate the current conditions
- Answer “Is it SQL Server”?
- Identify CPU consumers
- Match the pattern and resolve
Define the problem
First we need to scope the issue. When someone comes up to you and says they are seeing a CPU performance issue, this could mean any number of different things. So the first task is to understand what the nature of the CPU performance issue currently is.Some common categories include:
- Availability being impacted due to “pegged CPUs”. For example – all schedulers running at 100% across the board and throughput being stalled or significantly reduced.
- Degradation of performance due to “higher than normal” CPU usage. So we’re not pegged, but your CPUs are running at a higher percentage than is ordinary and presumably it is impacting performance.
- Another common category of CPU performance issue is the “winners and losers” scenario where workloads are competing against each other. Perhaps you have an OLTP workload that is encountering reduced throughput due to a parallel executing report query.
- Another problem might be the encountering of a tipping point – where the overall capacity and scalability limitations of your system are hit at a certain point.
Validate the current conditions
Whether the issue happened in the past or is happening right now, it is important to get as much background information about the system, workload and configurations as possible. If you’re using baselines and run-books, ideally you’re tracking much of this information already. If not, ask yourself how quickly you could get answers to these questions at 2AM in the middle of a crisis.The following sub-sections cover important data points that I’m typically interested in for a CPU-performance issue.
- How many sockets and cores?
- Is hyper-threading enabled?
- What is the processor model, architecture (32-bit/64-bit)?
- Is this a virtual guest?
- If so, you’re now also going to be interested in details about the host and the other virtual guests you’re sharing resources with.
- Are there any CPU-related settings in effect?
- For example, Hyper-V CPU
- How many vCPUs are allocated across guests?
- How many vCPUs does this guest have?
- Was the guest recently migrated to a new host prior to the issue?
- Max degree of parallelism setting
- Cost threshold for parallelism option
- Processor affinity setting
- Priority boost setting
- Max worker threads setting
- Lightweight pooling setting
- What is the power-option setting? (OS level, VM Host or BIOS controlled)
- High Performance, Balanced, Power Saving?
- Is it configured beyond the default settings?
- Do you see any unusual warnings or errors?
Physical server details
Virtual server details
Reserve, VMware CPU Reservation, Hyper-V CPU Relative Weight, and VMware CPU Shares.
SQL Server instance configuration settings
The first three configurations may require further discussion. There are rarely absolutes regarding these settings.
Regarding the last three settings, such as “priority boost”, if I see that they are at non-default values I’m definitely going to be pushing for more background information and history.
CPU power-option settings
Resource Governor configuration
I still find that it is rare to encounter customers using this feature at all, but it is easy to validate whether it is being used and will be worth it for the times that it is actually configured beyond the default.
SQL Server error log and Windows event logs
Why look in the error and event logs for a CPU issue? Sometimes upstream issues can cause downstream performance issues in SQL Server. You don’t want to waste time tuning a query or adding a new index when you’re upstream root-cause issue is a hardware component degradation issue.
Answer “Is it SQL Server?”
It sounds obvious when I ask it, but you really don’t want to spend a significant amount of time troubleshooting a high CPU issue in SQL Server if the culprit isn’t actually SQL Server.Instead, take a quick moment to check which process is consuming the most CPU. There are several options to choose from, including:
- Process: % User Time (user mode)
- Process: % Privileged Time (kernel mode)
- Task Manager
- Process Explorer
- Recent CPU information via sys.dm_os_ring_buffers or the system health session for the specific SQL Server instances running on the system
SELECT SERVERPROPERTY('processid')
to get the PID and then associating it to Task Manager or Process Explorer.Once you’ve confirmed it is SQL Server, are you seeing high user time or privileged (kernel) time? Again this can be confirmed via Process: % Privileged Time (sqlservr object) and also Windows Task Manager or Process Explorer.
While high kernel time issues should be rare, they still require different troubleshooting paths than standard user time CPU troubleshooting issues. Some potential causes of high kernel time include faulty filter-drivers (anti-virus, encryption services), out-of-date or missing firmware updates and drivers, or defective I/O components.
Identify CPU consumers
Once you’ve validated which SQL Server instance is driving the user-time CPU usage on the system, there are plenty of pre-canned query examples out on the web that you could use.Below is a list of DMVs that people commonly use in various forms during a performance issue. I structured this in a Q&A format to help frame why you would want to access them.
- sys.dm_exec_requests
- sys.dm_exec_sql_text
- sys.dm_exec_sessions
- sys.dm_exec_connections
- sys.dm_exec_query_plan
- sys.dm_os_waiting_tasks
- sys.dm_exec_query_stats
- Aggregate by total_worker_time
- Define averages with execution_count
- If ad hoc workloads, you could group by query_hash
- Use the plan_handle with sys.dm_exec_query_plan to grab the plan
- sys.dm_os_tasks
- Ordered by session_id, request_id
- sys.dm_exec_query_plan
- Look at plan operators – but keep in mind this is just the estimated plan
- sys.dm_exec_query_stats
- Filter total_elapsed_time less than total_worker_time
- But note that this can be a false negative for blocking scenarios – where duration is inflated due to a wait on resource
What requests are executing right now and what is their status?
What is it executing?
Where is it from?
What is its estimated plan? (but be careful of shredding xml on an already-CPU-constrained system)
Who’s waiting on a resource and what are they waiting for?
Which queries have taken up the most CPU time since the last restart?
Is this query using parallelism?
Match the pattern and resolve
You’re probably laughing at this particular step – as this one can be the most involved (and is another reason why SQL Server professionals are gainfully employed). There are several different patterns and associated resolutions – so I’ll finish this post with a list of the more common CPU performance issue drivers that I’ve seen over the last few years:- High I/O operations (and in my experience this is the most common driver of CPU)
- Cardinality estimate issues (and associated poor query plan quality)
- Unexpected parallelism
- Excessive compilation / recompilation
- Calculation-intensive UDF calls, shredding operations
- Row-by-agonizing row operations
- Concurrent maintenance activities (e.g. UPDATE stats with FULLSCAN)
Summary
As with any methodology, there are boundaries for its utilization and areas where you are justified in improvising. Please note that I’m not suggesting the steps I described in this post be used as a rigid framework, but instead consider it to be a launch-point for your troubleshooting efforts. Even highly experienced SQL Server professionals can make rookie mistakes or be biased by their more recent troubleshooting experiences, so having a minimal methodology can help avoid troubleshooting the wrong issue.
Subscribe to:
Posts (Atom)