Procedure stats getting cleared very often - sql

Recent days, in our organisation, we are facing with a strange issue.
Our SQL Server has enough memory(256 GB) and CPU cores. There is no memory pressure(outcome of dm_os_sys_memory is "Available physical memory is high").
Only problem is, the procedure stats sys.dm_exec_procedure_stats is getting cleared very often. Stats doesn't stay even for an hour.
The reason why we need the stats is, it is being collected on daily basis with the help of the DMV dm_exec_procedure_stats. And, our SQL Developers used to do optimization on stored procedures, and once it is done, to know the effectiveness of the tuning activity, a comparison is being done between the collected historical stats and the current one.
Since, the procedure stats is not staying on the cache, we are not able to set any benchmark.
Kindly suggest some solutions.
Version: Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Enterprise Edition: (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: )

There are a number of ways that the cache can get cleared from Overall instance config changes to Db changes through to using recompile in procedures.
This link gives a good lead on what may be causing the issue but I think you are going to have to do some investigating.
https://www.sqlskills.com/blogs/glenn/eight-different-ways-to-clear-the-sql-server-plan-cache/

Related

SQL Server 2019 Out of memory error message

Last weekend, we successfully migrated a SQL2016 AlwaysOnAG to a SQL 2019 AlwayOnAG. The new server has double the amount of memory (512GB), it's patched to CU12. OS is Windows Server 2019. Last night SQL crashed due to an "out of memory" error. As a result a failover took place. It looks like this error was caused by a rebuild of a columnstore index, because I saw a start of this action, but no completion time (we use the scripts from Ola Hallengren).
This index was already in the SQL2016 environment and no changes have been made since the migration (we're still in a "freeze"). Some things we are using: TDE, memory-optimized tempdb, in-memory tables, resource governor (disabled), polybase (but not used so far). Max memory for SQL is 448GB according to http://sqlmax.chuvash.eu/.
To me, an index rebuild should not result in this error. Any thoughts/ recommendations about this issue?

Queries running longer after license upgrade

We have been running SQL server 2012 Enterprise Evaluation version on our new DB server for last two weeks.
Things were working well for us until last night when we applied a SQL server 2012 standard license on this DB. We are seeing that after applying standard license DB our queries are taking much longer time to execute. This is not just an issue with one or two queries we are seeing this behaviour for all queries.
Is this behaviour because of license changes? Is there any way I can confirm this is actually because of license change?
It may very well be due to the license change. SQL Server Standard edition has limits on the number of processors and amount of memory that it can use. SQL Server Enterprise edition does not. Here is a link to an article with the specifics:
https://msdn.microsoft.com/en-us/library/cc645993(v=sql.110).aspx
Verifying that would be a challenge, unless you have another server box available with comparable horsepower where you can install SQL Server 2012 Enterprise Evaluation and then do side-by-side comparisons.

Sql Server 2005 - cannot obtain a LOCK resource

The observed problem and error message is:
The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users.Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions
Environment: SQL Server 2005 Standard edition on Windows server 2003 Standard edition. Virtualized on a VM - with 8 GB RAM
Automatic applications are processing data - reading raw data and writing results to the database. These applications get the error message and they crash on it. (There are also database backup and index maintenance jobs scheduled.)
The same error was never observed on a similar system with sql server 2005 enterprise edition and windows 2003 enterprise edition.
I have already searched the web and found some answers. But e.g.
SQL Server cannot obtain a LOCK resource at this time - What to do?
was not helpful in my case
One source suggested to check:
SELECT request_session_id, COUNT (*) num_locks
FROM sys.dm_tran_locks
GROUP BY request_session_id
ORDER BY count (*) DESC
One session came up with 10.
The memory and lock settings are both in the default settings.
My current idea is to purge most of the data which is old and can be removed.
Does anybody have any other ideas how to deal with the lock resource problem? What exactly is its cause? Does SQL server standard edition allow less resources - is the problem related to the sql server version? How to fix the issue?
The autoshrink function had multiple locks on the database catalog.
The autoshrink also fragmented the primary key of a table after rebuilding the primary key.
Switching off the autoshrink function has solved the problem

SQL Server Express Casues CPU to Peg at 100% on Single Core Tablet

I am running an instance of SQL Server Express on an old underpowered tablet PC used for a special purpose application. Periodically the SQL Server process kicks in and hammers the CPU at 100% bringing the application to a halt. (Technically, it doesn't halt, it just slows it down to the point where key processes time-out.) It will be another two or three years before the hardware is replaced so that's not an option. Is there a way to throttle SQL Server Express?
There are a few techniques to identify CPU-hogging activity on MSSQL, but since your box is completely unresponsive at the time, you have few options. Using SQL Profiler to run a background trace logging to a table or file might be your best bet.
Until very recently, you needed a paid version of MSSQL to use Profiler, however MS now includes Profiler with MSSQL Express 2012 SP1. Here's a direct download link:
http://www.microsoft.com/en-us/download/details.aspx?id=35579
(Note, you can probably install Profiler without upgrading your MSSQL server instance, if you don't want to).
If you've never used Profiler to diagnose CPU-hogging queries before, here's how I would suggest going about it:
new trace > connect to your MSSQL instace
make sure the "CPU" column is selected
make sure both the "started" and "completed" events for all the queries (Statement/Query/Batch/Procedure/etc) are checked.
Use a "column filter" to only show events where there is a value in the "CPU" column
Select a name for the trace, and a destination (table or .TRN file)
Start the trace and leave it running
After experiencing the CPU issue, once your box recovers: open the trace results, paying particular attention to the CPU column, and the date/time the 100% utilization started. Here's a link with more about using Profiler to analyze traces:
http://msdn.microsoft.com/en-us/library/ms175848.aspx

Possible Server Improvements?

I need an expert insight to my problem. most of my experience is development so i dont have enough grasp regarding server issues or maintenance. Main problem is when traffic is high request to this SQL server times out. there are several applications connecting to this server, some are web some are windows app. i would like to know if i need to do hardware upgrade(more ram, more hdisk space and how much of each is enough) or SQL server maintenance (rebuilding index, SP enhancement, denormalization etc.) or both?
OK first let me give you some specs of the server i'm having trouble with.
OS: MS Windows Server 2003 Standard
Version: 5.2.3790 SP 1 Build 3790
System Type: x64-based PC
Processor: EM64T Family 6 Model 15 Stepping 6 GenuinIntel ~2993 Mhz
RAM: 8gb
free C: space: 400mb
SQL Server Soft. Ver.: Sql Server 2005 Developer Edition
hope info above is enough for a diagnosis. my main concern initially is the available space in c:. also i'm looking at the RAM, i use perfmon and when traffic is high its reaching its max. as for CPU i have no idea but sometimes its running at 100% but its not always like that so i think its normal.
next question i think will be pointless because i cant give you sql db details but i will ask anyway. Will reindexing help or SP optimazation and to what extent? db is at 50+gb now
do we need a new server(hardware)?
Will Updating the sql server software help? from 2005 to 2008? is there an issue when your SQL server prod is only dev edition?
when you have an issue like this what could be the default fix or quick fix if there are any..
I hope an experienced Sys. Ad. or DBA or some programming god have pitty on me and enlighten me regarding this problem
Thanks in advance.
The first step would be to provide more useful information in your question. How does the server behave under pressure.
Use perfmon and or Sql Profiler http://msdn.microsoft.com/en-us/library/ms187929.aspx to log a number of data points while it is under load.
Also see Performance tuning with SQL Server and https://serverfault.com/questions/4700/how-to-do-periodic-sql-server-performance-monitoring-and-troubleshooting