{"id":137,"date":"2013-06-02T01:32:34","date_gmt":"2013-06-01T23:32:34","guid":{"rendered":"http:\/\/catyellow.net\/blog\/?p=137"},"modified":"2013-06-04T21:30:54","modified_gmt":"2013-06-04T19:30:54","slug":"quick-hint-analyzing-mysql-general-query-log","status":"publish","type":"post","link":"https:\/\/catyellow.net\/blog\/?p=137","title":{"rendered":"Quick hint: analyzing mysql general query log"},"content":{"rendered":"<p>I had a long running transaction and general log enabled.<br \/>\nSo I wanted to check which queries caused transaction to be running for a long time.<\/p>\n<p>If you have thread id for a long running transaction:<br \/>\n(you can get it from &#8220;mysql&gt; show engine innodb status;&#8221; or <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.2\/pt-deadlock-logger.html\" title=\"pt-deadlock-logger\" target=\"_blank\">pt-deadlock-logger<\/a> in case of deadlock)<br \/>\nthen you can grep log by thread id and then use <a href=\"http:\/\/www.percona.com\/doc\/percona-toolkit\/2.2\/pt-query-digest.html\" title=\"pt-query-digest\" target=\"_blank\">pt-query-digest<\/a> and analyze log<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo grep -i &quot; &lt;thread id&gt; &quot; &lt;genera-log-filename&gt; &gt; somefile.txt\r\nsudo pt-query-digest --type genlog  somefile.txt\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I had a long running transaction and general log enabled. So I wanted to check which queries caused transaction to be running for a long time. If you have thread id for a long running transaction: (you can get it from &#8220;mysql&gt; show engine innodb status;&#8221; or pt-deadlock-logger in case of deadlock) then you can [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3,39,38],"_links":{"self":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/137"}],"collection":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=137"}],"version-history":[{"count":6,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":144,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/137\/revisions\/144"}],"wp:attachment":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}