<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Profiler &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/sql-profiler/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Tue, 14 Nov 2017 08:05:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries</title>
		<link>https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/</link>
					<comments>https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 30 Jul 2016 19:59:04 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[profiling]]></category>
		<category><![CDATA[SHOW PROFILES]]></category>
		<category><![CDATA[SQL Profiler]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2153</guid>

					<description><![CDATA[Microsoft SQL Server Profiler is one of the important tool which is useful to find different events and statues of the running queries on Microsoft SQL Server. Do we have anything like SQL Profiler in MySQL? I have found this question on many forums and many of MySQL professionals are curious about SQL Profiler in [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&amp;linkname=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F07%2Fmysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries%2F&#038;title=MySQL%3A%20Using%20SQL%20Query%20Profiler%20finds%20total%20execution%20time%20and%20CPU%20information%20of%20the%20Queries" data-a2a-url="https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/" data-a2a-title="MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries"></a></p><p><em>Microsoft SQL Server Profiler is one of the important tool which is useful to find different events and statues of the running queries on Microsoft SQL Server.</em></p>
<blockquote><p><strong>Do we have anything like SQL Profiler in MySQL?</strong></p>
<p>I have found this question on many forums and many of MySQL professionals are curious about SQL Profiler in MySQL.</p></blockquote>
<blockquote><p>MySQL has SQL Profiler which is built into the database server and you can enable/disable via the MySQL client utility.</p></blockquote>
<blockquote><p>Before executing any queries you can enable SQL Profiler and it is only for your particular session.<br />
Internally, it creates one profiling table into INFORMATION_SCHEMA database and when you disconnect with MySQL client, it destroys this table.</p></blockquote>
<p><strong>Enable SQL Profile at session level:</strong></p><pre class="crayon-plain-tag">SET profiling=1;</pre><p>
<strong>Execute sample query:</strong></p><pre class="crayon-plain-tag">SELECT *FROM table_one;
SELECT *FROM table_two;</pre><p>
<strong>Check the execution time for each query:</strong></p><pre class="crayon-plain-tag">SHOW PROFILES;

/*Result*/
Query_ID   Duration    Query
--------------------------------------------------
1          0.00355325  SELECT *FROM table_one
2          0.00051850  SELECT *FROM table_two</pre><p>
<strong>Check the execution time for second query only:</strong></p><pre class="crayon-plain-tag">SHOW PROFILE FOR QUERY 2;</pre><p>
<strong>Check the CPU information for second query only:</strong></p><pre class="crayon-plain-tag">SHOW PROFILE CPU FOR QUERY 2;</pre><p>
<strong>The Result:</strong></p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCPUSQLProfiler.png" rel="attachment wp-att-2160"><img fetchpriority="high" decoding="async" class="alignnone wp-image-2160 size-full" title="MySQL CPU SQL Profiler" src="https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCPUSQLProfiler.png" alt="MySQL CPU SQL Profiler" width="316" height="350" srcset="https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCPUSQLProfiler.png 316w, https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCPUSQLProfiler-271x300.png 271w, https://www.dbrnd.com/wp-content/uploads/2016/03/MySQLCPUSQLProfiler-150x166.png 150w" sizes="(max-width: 316px) 100vw, 316px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server: 8 different ways to Detect a DeadLock in a Database</title>
		<link>https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/</link>
					<comments>https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 09 Apr 2016 19:00:49 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DeadLock]]></category>
		<category><![CDATA[dm_os_performance_counters]]></category>
		<category><![CDATA[DMV]]></category>
		<category><![CDATA[extended event]]></category>
		<category><![CDATA[sp_lock]]></category>
		<category><![CDATA[SQL Profiler]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tunning]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=2341</guid>

					<description><![CDATA[In the previous post, I shared T-SQL script to generate a DeadLock situation in SQL Server Database. In this post, I am sharing different scripts to detect a Deadlock in SQL Server. 1. Using SP_LOCK, you can find the WAIT status for blocking sessions: [crayon-6ab31b6048cb6576102400/] 2. Using sys.sysprocesses: [crayon-6ab31b6048cb8132211083/] 3. Using common DMV: [crayon-6ab31b6048cb9174288923/] 4. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&amp;linkname=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F04%2Fsql-server-8-different-ways-to-detect-a-deadlock-in-a-database%2F&#038;title=SQL%20Server%3A%208%20different%20ways%20to%20Detect%20a%20DeadLock%20in%20a%20Database" data-a2a-url="https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/" data-a2a-title="SQL Server: 8 different ways to Detect a DeadLock in a Database"></a></p><p>In the previous post, I shared T-SQL script to generate a DeadLock situation in SQL Server Database.<br />
In this post, I am sharing different scripts to detect a Deadlock in SQL Server. </p>
<p><strong>1. Using SP_LOCK, you can find the WAIT status for blocking sessions:</strong></p><pre class="crayon-plain-tag">SP_LOCK</pre><p>
<a href="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerSP_Lock.png" rel="attachment wp-att-2344"><img decoding="async" class="alignnone wp-image-2344 size-full" title="SQL Server SP_Lock" src="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerSP_Lock.png" alt="SQL Server SP_Lock" width="401" height="218" srcset="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerSP_Lock.png 401w, https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerSP_Lock-300x163.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerSP_Lock-150x82.png 150w" sizes="(max-width: 401px) 100vw, 401px" /></a></p>
<p><strong>2. Using sys.sysprocesses:</strong></p><pre class="crayon-plain-tag">SELECT * FROM sys.sysprocesses 
WHERE blocked &gt; 0</pre><p>
<p><strong>3. Using common DMV:</strong></p><pre class="crayon-plain-tag">SELECT 	
	der.blocking_session_id AS BlockingSessionID
	,dest.text AS BlockingStatement
FROM sys.dm_exec_connections AS sdec
INNER JOIN sys.dm_exec_requests AS der
    ON sdec.session_id = der.blocking_session_id
INNER JOIN sys.dm_os_waiting_tasks AS dowt
    ON der.session_id = dowt.session_id
CROSS APPLY sys.dm_exec_sql_text(sdec.most_recent_sql_handle) AS dest</pre><p>
<p><strong>4. Using sys.dm_tran_locks:</strong></p><pre class="crayon-plain-tag">SELECT 
	request_session_id AS SPID 
	,DB_NAME(resource_database_id) AS DatabaseName
	,resource_type AS LockedResource
	,request_mode AS LockType
FROM sys.dm_tran_locks</pre><p>
<p><strong>5. Enable required trace flags to log DeadLock related information in Tracefile:</strong></p><pre class="crayon-plain-tag">DBCC TRACEON (1204, -1)
DBCC TRACEON (1222, -1)</pre><p>
<p><strong>6. Count total number of DeadLock:</strong></p><pre class="crayon-plain-tag">SELECT cntr_value AS TotalNumberOfDeadLocks
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Number of Deadlocks/sec'
   AND instance_name = '_Total'</pre><p>
<p><strong>7. Using Extended Events and below script to create Extended Event for monitoring the DeadLock:</strong></p><pre class="crayon-plain-tag">CREATE EVENT SESSION [Deadlock_Monitor] ON SERVER 
ADD EVENT sqlos.scheduler_monitor_deadlock_ring_buffer_recorded,
ADD EVENT sqlserver.lock_deadlock,
ADD EVENT sqlserver.lock_deadlock_chain,
ADD EVENT sqlserver.xml_deadlock_report 
ADD TARGET package0.event_file(SET filename=N'C:\Temp\Deadlock_Monitor.xel')
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
GO</pre><p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlock.png" rel="attachment wp-att-2345"><img decoding="async" class="alignnone wp-image-2345 size-full" title="SQL Server Extended Event For Deadlock" src="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlock.png" alt="SQL Server Extended Event For Deadlock" width="359" height="146" srcset="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlock.png 359w, https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlock-300x122.png 300w, https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlock-150x61.png 150w" sizes="(max-width: 359px) 100vw, 359px" /></a></p>
<p>You can also use SSMS to create Extended Events for DeadLock, and you can monitor the live status of the server.</p>
<p><a href="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlockInSSMS.png" rel="attachment wp-att-2346"><img loading="lazy" decoding="async" class="alignnone wp-image-2346 size-full" title="SQL Server Extended Event For Deadlock In SSMS" src="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlockInSSMS.png" alt="SQL Server Extended Event For Deadlock In SSMS" width="208" height="167" srcset="https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlockInSSMS.png 208w, https://www.dbrnd.com/wp-content/uploads/2016/04/SQLServerExtendedEventForDeadlockInSSMS-150x120.png 150w" sizes="auto, (max-width: 208px) 100vw, 208px" /></a></p>
<p><strong>8. Using SQL Server Profiler: </strong><br />
SQL Server Profiler has three different events to capture a deadlock.<br />
<pre class="crayon-plain-tag">1.Deadlock graph
2.Lock: Deadlock
3.Lock: Deadlock Chain</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/04/sql-server-8-different-ways-to-detect-a-deadlock-in-a-database/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
