Вы находитесь на странице: 1из 3

SELECT * FROM sys.

all_objects
WHERE [name] LIKE '%dm_%'
AND [type] IN ('V', 'TF', 'IF')
ORDER BY [name]
select * from sys.dm_os_memory_clerks
select * from sys.dm_os_memory_objects
SELECT
physical_memory_kb/1024.0 AS Physical_memory_in_Mb
FROM
sys.dm_os_sys_info
--This DMV uses RING_BUFFER_RESOURCE_MONITOR and gives information from resource
monitor notifications to
--identify memory state changes. Internally, SQL Server has a framework that mon
itors different memory pressures.
--When the memory state changes, the resource monitor task generates a notificat
ion.
--This notification is used internally by the components to adjust their memory
usage according to the memory state.
SELECT
Record FROM sys.dm_os_ring_buffers
WHERE ring_buffer_type = 'RING_BUFFER_RESOURCE_MONITOR'
SELECT
record FROM sys.dm_os_ring_buffers
WHERE ring_buffer_type = 'RING_BUFFER_OOM'
-- Message we get // <Record id = "664" type ="RING_BUFFER_RESOURCE_MONITOR" tim
e ="180653487"><ResourceMonitor><Notification>
--RESOURCE_MEMPHYSICAL_HIGH</Notification><IndicatorsProcess>0</IndicatorsProces
s><IndicatorsSystem>1</IndicatorsSystem>
--<NodeId>0</NodeId><Effect type="APPLY_LOWPM" state="EFFECT_OFF" reversed="0">0
</Effect><Effect type="APPLY_HIGHPM"
--state="EFFECT_OFF" reversed="0">0</Effect><Effect type="REVERT_HIGHPM" state="
EFFECT_IGNORE" reversed="0">399852</Effect>
--</ResourceMonitor><MemoryNode id="0"><TargetMemory>438536</TargetMemory><Reser
vedMemory>5890080</ReservedMemory>
--<CommittedMemory>98324</CommittedMemory><SharedMemory>0</SharedMemory><AWEMemo
ry>0</AWEMemory><PagesMemory>64864</PagesMemory>
--</MemoryNode><MemoryRecord><MemoryUtilization>57</MemoryUtilization><TotalPhys
icalMemory>1943724</TotalPhysicalMemory>
--<AvailablePhysicalMemory>437400</AvailablePhysicalMemory><TotalPageFile>351658
8</TotalPageFile><AvailablePageFile>774312</AvailablePageFile>
--<TotalVirtualAddressSpace>137438953344</TotalVirtualAddressSpace><AvailableVir
tualAddressSpace>137432722236</AvailableVirtualAddressSpace>
--<AvailableExtendedVirtualAddressSpace>0</AvailableExtendedVirtualAddressSpace>
</MemoryRecord></Record>

SELECT
scheduler_id,current_tasks_count,runnable_tasks_count
FROM sys.dm_os_schedulers
WHERE scheduler_id < 255
--Sys.dm_os_schedulers view will help you identify if there is any CPU bottlenec
k in the SQL Server machine.
--The number of runnable tasks is generally a nonzero value; a nonzero value ind
icates that tasks have to wait for their time slice to run.
--If the runnable task counts show high values, then there is a symptom of CPU b
ottleneck.

select * from sys.dm_io_pending_io_requests


SELECT * FROM sys.dm_io_virtual_file_stats(DB_ID(N'AdventureWorks2012'), 2);
GO
USE MSDB;
GO
SELECT * FROM sys.dm_db_partition_stats;
USE MSDB
GO
SELECT * FROM sys.dm_db_partition_stats WHERE object_id = OBJECT_ID('backupset')
;
SELECT instance_name,cntr_value 'Log File(s) Used Size (KB)'FROM sys.dm_os_perfo
rmance_counters WHERE counter_name = 'Log File(s) Used Size (KB)'
SELECT object_id, index_id, user_seeks, user_scans, user_lookups FROM sys.dm_db_
index_usage_stats ORDER BY object_id, index_id

SELECT object_name(i.object_id),
i.name,
s.user_updates,
s.user_seeks,
s.user_scans,
s.user_lookups
from sys.indexes i
left join sys.dm_db_index_usage_stats s on s.object_id = i.object_id and i.index
_id = s.index_id and s.database_id = 5
where objectproperty(i.object_id, 'IsIndexable') = 1 and s.index_id is null or (
s.user_updates > 0 and s.user_seeks = 0
and s.user_scans = 0 and s.user_lookups = 0) order by object_name(i.object_id)

SELECT session_id,login_name,last_request_end_time,cpu_time FROM sys.dm_exec_ses


sions WHERE session_id >= 51

SELECT connection_id, session_id,client_net_address, auth_scheme FROM sys.dm_exe


c_connections

SELECT session_id,status, command,sql_handle,database_id FROM sys.dm_exec_reques


ts WHERE session_id >= 51

SELECT
st.text
FROM
sys.dm_exec_requests r
CROSS APPLY
sys.dm_exec_sql_text(sql_handle) AS st
WHERE r.session_id = 51
//Last server restart
SELECT
[ms_ticks] AS ms_since_restart,
[ms_ticks]/1000 AS seconds_since_restart,
CAST([ms_ticks]/1000/60.0 AS DECIMAL(15,2)) AS minutes_since_restart,
CAST([ms_ticks]/1000/60/60.0 AS DECIMAL(15,2)) AS hours_since_restart,
CAST([ms_ticks]/1000/60/60/24.0 AS DECIMAL(15,2)) AS days_since_restart,
DATEADD(s,((-1)*([ms_ticks]/1000)),GETDATE()) AS time_of_last_restart
FROM sys.[dm_os_sys_info];
SELECT
DATEADD(s,((-1)*(DOSI.[ms_ticks]/1000)),GETDATE()) AS last_SERVER_restart,
D.create_date,
(DATEDIFF(s, DATEADD(s,((-1)*(DOSI.[ms_ticks]/1000)),GETDATE()), D.create_date))
AS recovery_time_seconds
FROM sys.[dm_os_sys_info] DOSI
CROSS JOIN sys.[databases] D
WHERE D.[name] = 'tempdb';
SELECT
DATEADD(s,((-1)*(DOSI.[ms_ticks]/1000)),GETDATE()) AS last_SERVER_restart,
DOSI.sqlserver_start_time,
(DATEDIFF(s, DATEADD(s,((-1)*(DOSI.[ms_ticks]/1000)),GETDATE()), DOSI.sqlserver_
start_time)) AS recovery_time_seconds
FROM sys.[dm_os_sys_info] DOSI;

Вам также может понравиться