<?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>performance_schema.events_statements_history &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/performance_schema-events_statements_history/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, 07 Mar 2017 19:17:52 +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: Script to find Long Running Queries and Transactions</title>
		<link>https://www.dbrnd.com/2017/01/mysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema/</link>
					<comments>https://www.dbrnd.com/2017/01/mysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 25 Jan 2017 23:16:31 +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[information_schema.innodb_trx]]></category>
		<category><![CDATA[INFORMATION_SCHEMA.PROCESSLIST]]></category>
		<category><![CDATA[long running query]]></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[performance schema]]></category>
		<category><![CDATA[performance_schema.events_statements_history]]></category>
		<category><![CDATA[processlist]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3736</guid>

					<description><![CDATA[Don&#8217;t you think so that finding Long Running Queries are a very common requirement for a Database Administrator? &#8216; Yes, Database Administrators are always looking for a list of Long Running Queries. In this post, I am sharing scripts to find Long Running Queries or Transactions of MySQL Database Server. MySQL DBA can use this [&#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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&amp;linkname=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" 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%2F2017%2F01%2Fmysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema%2F&#038;title=MySQL%3A%20Script%20to%20find%20Long%20Running%20Queries%20and%20Transactions" data-a2a-url="https://www.dbrnd.com/2017/01/mysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema/" data-a2a-title="MySQL: Script to find Long Running Queries and Transactions"></a></p><p>Don&#8217;t you think so that finding Long Running Queries are a very common requirement for a Database Administrator? &#8216;</p>
<blockquote><p>Yes, Database Administrators are always looking for a list of Long Running Queries. </p></blockquote>
<blockquote><p>In this post, I am sharing scripts to find Long Running Queries or Transactions of MySQL Database Server. </p></blockquote>
<blockquote><p>MySQL DBA can use this script to take necessary steps against the bad and long running queries which increase the overall performance of MySQL Database Server.</p></blockquote>
<p>In below script, I set 59 seconds internal to find long running query since last 59 seconds.<br />
As per your requirement, you can change this value. </p>
<p>Here, You can also visit few related articles.</p>
<blockquote data-secret="AeA5F0w02e" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2015/11/mysql-how-to-log-general-and-long-running-queries-into-log-table/">MySQL: How to Log General and Long Running Queries into Log Table</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/11/mysql-how-to-log-general-and-long-running-queries-into-log-table/embed/#?secret=AeA5F0w02e" data-secret="AeA5F0w02e" width="600" height="338" title="&#8220;MySQL: How to Log General and Long Running Queries into Log Table&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote data-secret="I52mPLNNBx" class="wp-embedded-content"><p><a href="https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/">MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/07/mysql-using-sql-query-profiler-finds-total-execution-time-and-cpu-information-of-the-queries/embed/#?secret=I52mPLNNBx" data-secret="I52mPLNNBx" width="600" height="338" title="&#8220;MySQL: Using SQL Query Profiler finds total execution time and CPU information of the Queries&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Script without using Performance_schema:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	trx.trx_id
	,trx.trx_started
	,trx.trx_mysql_thread_id
FROM INFORMATION_SCHEMA.INNODB_TRX AS trx
INNER JOIN INFORMATION_SCHEMA.PROCESSLIST AS pl 
	ON trx.trx_mysql_thread_id = pl.id
WHERE trx.trx_started &lt; CURRENT_TIMESTAMP - INTERVAL 59 SECOND
  AND pl.user &lt;&gt; 'system_user';</pre> </p>
<p><strong>Script using Performance_schema:</strong></p>
<pre class="crayon-plain-tag">SELECT 
	pl.id 'PROCESS ID'
	,trx.trx_started
	,esh.event_name 'EVENT NAME'
	,esh.sql_text 'SQL'
FROM information_schema.innodb_trx AS trx
INNER JOIN information_schema.processlist pl 
	ON trx.trx_mysql_thread_id = pl.id
INNER JOIN performance_schema.threads th 
	ON th.processlist_id = trx.trx_mysql_thread_id
INNER JOIN performance_schema.events_statements_history esh 
	ON esh.thread_id = th.thread_id
WHERE trx.trx_started &lt; CURRENT_TIME - INTERVAL 59 SECOND
  AND pl.user &lt;&gt; 'system_user'
ORDER BY esh.EVENT_ID;</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/01/mysql-script-to-find-long-running-queries-and-transactions-information_schema-innodb_trx-processlist-performance_schema/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
