Posts

Showing posts from February, 2017

Finding which WAIT TYPE is high at SQL Server end.

Image
WITH Waits AS ( SELECT wait_type, wait_time_ms / 1000. AS wait_time_s, 100. * wait_time_ms / SUM(wait_time_ms) OVER() AS pct, ROW_NUMBER() OVER(ORDER BY wait_time_ms DESC) AS rn FROM sys.dm_os_wait_stats WHERE wait_type NOT IN ('CLR_SEMAPHORE', 'LAZYWRITER_SLEEP', 'RESOURCE_QUEUE', 'SLEEP_TASK', 'SLEEP_SYSTEMTASK', 'SQLTRACE_BUFFER_FLUSH', 'WAITFOR', 'CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT') ) -- filter out additional irrelevant waits SELECT W1.wait_type, CAST(W1.wait_time_s AS DECIMAL(12, 2)) AS wait_time_s, CAST(W1.pct AS DECIMAL(12, 2)) AS pct, CAST(SUM(W2.pct) AS DECIMAL(12, 2)) AS running_pct FROM Waits AS W1 INNER JOIN Waits AS W2 ON W2.rn <= W1.rn GROUP BY W1.rn, W1.wait_type, W1.wait_time_s, W1.pct HAVING SUM(W2.pct) - W1.pct < 95; -- percentage threshold; If you see here "PCT" column is percentage column if this percentage is high then there

Windows Run ShortCuts

Just mention a couple of commands which uses for Windows.Go to command prompt and run these commands. NCPA.CPL CONTROL-->ControlPanel APPWIZ.CPL-->For Uninstall/Install programs COMPMGMT.MSC-->Computer Management DISKMGMT.MSC-->Disk Management TASKMGR-->TaskManager MSINFO32-->SystemInformation WINVER-->Windows versionm MSCONFIG-->System Configuration NSLOOKUP-->Default Server CONTROL ADMINTOOLS--> Admin Tools SET L-->Local App Data TASKLIST

Example For DeadLock

The dead lock behavior would be like this. This is just for  understand purpose.   In the below i have chosen another tables.                         Session1                                     Session2 1. Begin Transaction 1. Begin Transaction 2. Update Part table 2. Update Supplier table 3. Update  Supplier  table 3. Update  Part  table 4. Commit Transaction 4. Commit Transaction CREATE TABLE authors (id VARCHAR(20),Lname VARCHAR(30),Value1 VARCHAR(30),Value2 VARCHAR(30),Value3 VARCHAR(30),Value4 VARCHAR(30),Value5 VARCHAR(30),SomeValue VARCHAR(30),Sno INT) GO ---1 st window DECLARE @Au_ID VARCHAR(11) DECLARE @Au_lname VARCHAR(30) SELECT @Au_ID='111-11-1112',@Au_lname='Test1' BEGIN TRAN INSERT INTO authors VALUES(@Au_ID,@Au_lname,' ',' ',' ',' ',' ','11111',0) WAITFOR DELAY '00:00:05' SELECT * FROM Authors WHERE Lname like 'Test%' COMMIT ------2nd Window DECLARE