About Me
- Mohamed Faizal
- Barking, Essex, United Kingdom
- MCITP DBA ,MCITP BI & Oracle OCP 11G
Thursday, August 18, 2016
SQL to check the queries waittype
Friday, July 29, 2016
Find the sp cache
Tuesday, May 10, 2016
CX Packet Diagnosis
When query uses the parallel threads .i.e available cores assign the threads and execute them. Under these scenarios coordinator wait for the query to be completed.
If another same query executes and uses the same parallel threads and the wait is known as CX packet wait-type.
E.g We can inspect the execution plan and how many rows are distributed in the threads . If it's not equal then one threads will complete quickly those has minimum pages of rows to read and another thread still needs to process due to high pages reads ....so the coordinator wait for another thread to be completed.
To find the wait-type
Declare @spid int
SELECT session_id ,status ,blocking_session_id
,wait_type ,wait_time ,wait_resource
,transaction_id
FROM sys.dm_exec_requests
WHERE status = N'suspended' and session_id=@spid;
GO
To find the coordinator thread and it's associated parallel threads
SELECT
task_state, ---wait-type
exec_context_id, ---coordinator
parent_task_address, --parent task o\null means coordinator
task_address ---associated thread work resource address
FROM sys.dm_os_tasks
where session_id =@spid
--To detect further status of coordinator wait-type and it's threads
select wait_type,exec_context_id,blocking_exec_context_id,waiting_task_address,blocking_task_address
from sys.dm_os_waiting_tasks
-- To detect the query which coordinator scheduler_id is running or which core is executing ....
select scheduler_id from sys.dm_exec_requeusts.
This information is useful if more than one request processed on the same scheduler_id or core then the remaining request waiting for the coordinator to be completed or wait for the particular core to be available.
What is sleep task
To get number of rows written in each page for the particluar table
SELECT record_count/page_count as Avgrecords FROM sys.dm_db_index_physical_stats
(DB_ID(N'dbname'), OBJECT_ID(N'dbo.tablename'), NULL, NULL , 'DETAILED')
where index_level=0
--To get the details of CX packet as it sense how many pages waited in the sleep task . i.e if the query were used in intensive CPU and the same thread used for another request.
The quantum wait-type for each pages to be scheduled in the thread may be 4 ms can be found on sys.dm_os_sys_info . if you have the total value of waiting_tasks_counts then divide by number of threads used in the particular query and multiply the rows result based on the above value produced by sys.dm_db_index_physical_stats.
SELECT
wait_type, waiting_tasks_count
, wait_time_ms, max_wait_time_ms, signal_wait_time_ms
FROM sys.dm_os_wait_stats
Thursday, March 24, 2016
Capture the running sql block for the particular spid
Tuesday, February 23, 2016
Unused index List Automatic report
USE [DBA]
#box-table
{
font-family: "Lucida Sans
Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
text-align: center;
border-collapse: collapse;
border-top: 14px solid #9baff1;
border-bottom: 14px solid #9baff1;
}
#box-table th
{
font-size: 13px;
font-weight: normal;
background: #b9c9fe;
border-right: 2px solid #9baff1;
border-left: 2px solid #9baff1;
border-bottom: 2px solid #9baff1;
color: #039;
}
#box-table td
{
border-right: 1px solid #aabcfe;
border-left: 1px solid #aabcfe;
border-bottom: 1px solid #aabcfe;
color: #669;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
'+
Unused Index List
' +DBNAME
OBJECTNAME
INDEXNAME
USER_SEEKS
USER_SCANS
USER_LOOKUPS
USER_UPDATES
GO
Find out the disabled indexes
Find out the unused indexes
Thursday, February 18, 2016
Blocking Alert -Setup
#box-table
{
font-family: "Lucida Sans
Unicode", "Lucida Grande", Sans-Serif;
font-size: 15px;
text-align: center;
border-collapse: collapse;
border-top: 7px solid #9baff1;
border-bottom: 7px solid #9baff1;
}
#box-table th
{
font-size: 20px;
font-weight: normal;
background: #b9c9fe;
border-right: 2px solid #9baff1;
border-left: 2px solid #9baff1;
border-bottom: 2px solid #9baff1;
color: #039;
}
#box-table td
{
border-right: 1px solid #aabcfe;
border-left: 1px solid #aabcfe;
border-bottom: 1px solid #aabcfe;
color: #669;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
'+
Blocking Alert
' +Blocking Status - Resolved Automatically
'
#box-table
{
font-family: "Lucida Sans
Unicode", "Lucida Grande", Sans-Serif;
font-size: 15px;
text-align: center;
border-collapse: collapse;
border-top: 7px solid #9baff1;
border-bottom: 7px solid #9baff1;
}
#box-table th
{
font-size: 20px;
font-weight: normal;
background: #b9c9fe;
border-right: 2px solid #9baff1;
border-left: 2px solid #9baff1;
border-bottom: 2px solid #9baff1;
color: #039;
}
#box-table td
{
border-right: 1px solid #aabcfe;
border-left: 1px solid #aabcfe;
border-bottom: 1px solid #aabcfe;
color: #669;
}
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
'+