How to get procedure cache hit ratio in sybase by using query? - sybase

I have installed sybase setup in my local now I want check the procedure cache Hit ratio by using query.
Please help on this, because I am new on sybase and I need to collect procedure cache hit ratio for some purpose.

Related

Large USERSTORE_OBJPERM in SQL Server

I'm trying to make our SQL Server go faster and have noticed that no stored procedures are staying in the plan cache for any length of time. Most have of the plans have been created in the last hour or so.
Running the script below I see that the USERSTORE_OBJPERM is around 3GB and is the 2nd biggest memory cache on the server after the SQL BUFFERPOOL.
SELECT top 100 *
FROM sys.dm_os_memory_clerks
where type = 'USERSTORE_OBJPERM'
I've run the same script on a few other of our production servers and none of the USERSTORE_OBJPERM on the other servers are any where near as large around 200MBs.
My question is has anyone seen a USERSTORE_OBJPERM at around 3GB and what might of caused it.
I ran the following to try and clear the cache, it went down down by a 100mb or so and instantly started rising again.
DBCC FREESYSTEMCACHE ('ObjPerm - DatabaseName')
Results of script
SQL Server version is 2017 Enterprise with CU22 applied.
Many Thanks in advance for any tips or advice provided
Cheers Mat
Fixed.
It seems the issue was caused by an application using service broker.
The application was running a script to check permissions every 30 seconds.
Fortunately there was an option to switch the permission check off.
The USERSTORE_OBJPERM cache size is now 200MBs instead of 3GB and stored procedure plans are staying in the cache.

SQL Server 2005- Investigate what caused tempdb to grow huge

The tempdb of my instance grew huge eating up all the available disk space and causing applications to go down. Had to restart the instance in emergency. However, I want to investigate and dig deep as to what caused the temp db to grow huge all of sudden. What were the queries, processes that casued this? Can someone help me to pull the required info. I know I wont get much of historical Data from the SQL serevr. I do have the Idera SQL Diagnostic Manager(third party tool) deployed. Any help to use the tool would be really appreciated.
As for postmortem analysis, you can use the tools already installed on your server. For future proactive analysis, you can use SQL traces directly in SQL Profiler, or query the traces using SQL statements.
sys.fn_trace_gettable
sys.trace_events
You can also use an auditing tool that tracks every event that happened on a SQL Server instance and databases, such as ApexSQL Comply. It also uses SQL traces, configures them automatically,and processes captured information. It tracks object and data access and changes, failed and successful logins, security changes, etc. ApexSQL Comply loads all captured information into a centralized repository.
There are several reasons that might cause your tempdb to get very big.
A lot of sorting – if this requires more memory than your sql server has then it will store all temp results in tempdb
DBCC commands – if you’re frequently running commands such as DBCC CheckDB this might be the cause. These functions store its results in temp db
Very large resultsets – these are also using temp db to run properly
A lot of heavy transactions such as bulk inserts
Check out this article for more details http://msdn.microsoft.com/en-us/library/ms176029.aspx on how to troubleshoot this.
AK2,
We have Idera DM tool as well. If you know the time frame around what time your tempdb was used heavily you can go to History on the Idera tool to see what query was running at that time and what lead to the server to hose... On the "Tempdb Space used OverTime" you would usually see a straight line or a graph but at the time of heavy use of tempdb there's a pike and a straight drop. Referring to this time-frame you can check into Sessions>Details too see the exact query and who was running the query.
In our server this happens usually when there is a long query doing lots of join. or when there is an expensive query involving in dumping into temp table / table variable.
Hope this will help.
You can use SQL Profiler. Please try the link below
Sql Profiler

Prevent Caching in SQL Server

Having looked around the net using Uncle Google, I cannot find an answer to this question:
What is the best way to monitor the performance and responsiveness of production servers running IIS and MS SQL Server 2005?
I'm currently using Pingdom and would like it to point to a URL which basically mimics a 'real world query' but for obvious reasons do not want the query to run from cache. The URL will be called every 5 minutes.
I cannot clear out the cache, buffers, etc since this would impact negatively on the production server. I have tried using a random generated number within the SELECT statement in order to generate unique queries, but the cached query is still used.
Is there any way to simulate the NO_CACHE in MySQL?
Regards
To clear the SQL buffer and plan cache:
DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO
A little info about these commands from MSDN:
Use DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server. (source)
Use DBCC FREEPROCCACHE to clear the plan cache carefully. Freeing the plan cache causes, for example, a stored procedure to be recompiled instead of reused from the cache. (source)
SQL Server does not have a results cache like MySQL or Oracle, so I am a bit confused about your question. If you want the server to recompile the plan cache for a stored procedure, you can execute it WITH RECOMPILE. You can drop your buffer cache, but that would affect all queries as you know.
At my company, we test availability and performance separately. I would suggest you use this query just to make sure you your system is working together from front-end to database, then write other tests that check the individual components to judge performance. SQL Server comes with an amazing amount of ways to check if you are experiencing bottlenecks and where they are. I use PerfMon and DMVs extensively. Using PerfMon, I check CPU and page life expectancy, as well as seeing how long my disk queue is. Using DMVs, I can find out if my queries are taking too long (sys.dm_exec_query_stats) or if wait times are long (sys.dm_os_wait_stats).
The two biggest bottlenecks with IIS tend to be CPU and memory, and IIS comes with its own suite of PerfMon objects to query, but I am not as familiar with those.

Where can i find the: 1) cache hits and 2) cache lookup stats in SQL Server

First of, the question is not: how to see SQL Server cache hit rate!
For that one i already know of a view that contains that precises statistic.
My question is in fact: where are the raw statistics from where the hit ratio is calculated?
Sql server, in msdn pages, states that the cache hit ratio is the total cache hits divided by the total cache lookups. So I am assuming that the RDBMS is storing these two values somewhere.
Anyone know where i can access them?
I believe that the exact metrics you seek are available via the Dynamic Management View (DMV):
sys.dm_os_performance_counters
For example:
Select *
from sys.dm_os_performance_counters
WHERE OBJECT_NAME='SQLServer:Buffer Manager'
You can also use the Windows Performance Monitor to review the Buffer Cache statistics:
The SQL Server Buffer Pool and
Buffer Cache
For detailed information regarding the metrics concerning SQL Server Buffer Management consult the reference:
SQL Server, Buffer Manager
Object
To get detailed information regarding all of the SQL Server Memory space use the command:
DBCC memorystatus
Note: Regarding point 2) of the question, Page lookups == cache lookups and again this information is available in the afformentioned DMV.
If you have access to SQL Server then you can start SQL Server Profiler which will show you all the queries running on database. Keep SQL Server Profiler running & start recorded web test (like in VSTS Web Test).
At least looking at running trace will give you good idea of how many times db is accessed.
Suppose you query is
select * from customer
see how many times it occurs in trace.
Let's say 200 times
& number of test iterations, let's say 800.
Then 800/(800-200) = cache hit ratio.

How to let SQL Server know not to use Cache in Queries?

Just a general question:
Is there a query/command I can pass to SQL Server not to use cache when executing a particularly query?
I am looking for a query/command that I can set rather than a configuration setting. Is there no need to do this?
DBCC FREEPROCCACHE
Will remove all cached procedures execution plans. This would cause all subsequent procedure calls to be recompiled.
Adding WITH RECOMPILE to a procedure definition would cause the procedure to be recompiled every time it was called.
I do not believe that (in SQL 2005 or earlier) there is any way to clear the procedrue cache of a single procedures execution plan, and I'd doubt you could do it in 2008 either.
If you want to force a query to not use the data cache, the best approach is to clear the cache before you run the query:
CHECKPOINT
DBCC DROPCLEANBUFFERS
Note that forcing a recompile will have no effect on the query's use of the data cache.
One reason you can't just mark an individual query to avoid the cache is the cache use is an integral part of executing the query. If the data is already in cache, then what would SQL Server do with the data if it was read a second time? Not to mention sync issues, etc.
Another more localized way to not use the MS-SQL Server Cache is to use the OPTION(RECOMPILE) keyword at the end of your statement.
E.g.
SELECT Columnname
FROM TableName
OPTION(RECOMPILE)
For more information about this and other similar query-cache clues to help identify problems with a query, Pinal Dave (no affiliation) has some helpful info about this.
use
WITH RECOMPILE

Resources