<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Neat tricks for the MySQL command-line pager</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/</link>
	<description>Percona&#039;s MySQL &#38; InnoDB performance and scalability blog</description>
	<lastBuildDate>Sat, 11 Feb 2012 16:45:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Derek</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-772983</link>
		<dc:creator>Derek</dc:creator>
		<pubDate>Thu, 02 Sep 2010 08:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-772983</guid>
		<description>Just look for mysql pager info on: http://linux-sysadmin.org/2010/08/mysql-pager-filter-your-output/</description>
		<content:encoded><![CDATA[<p>Just look for mysql pager info on: <a href="http://linux-sysadmin.org/2010/08/mysql-pager-filter-your-output/" rel="nofollow">http://linux-sysadmin.org/2010/08/mysql-pager-filter-your-output/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Benton</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-447472</link>
		<dc:creator>Kevin Benton</dc:creator>
		<pubDate>Sat, 17 Jan 2009 04:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-447472</guid>
		<description>All - these are a nice set of improvements when using the command-line mysql.  I took this a few steps further when looking more into mytop by Jeremy Zawodny.  Want to see more - browse to th blog :-)  http://kbcmdba.blogspot.com/2009/01/easy-editing-with-mysql-command-line.html</description>
		<content:encoded><![CDATA[<p>All &#8211; these are a nice set of improvements when using the command-line mysql.  I took this a few steps further when looking more into mytop by Jeremy Zawodny.  Want to see more &#8211; browse to th blog <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   <a href="http://kbcmdba.blogspot.com/2009/01/easy-editing-with-mysql-command-line.html" rel="nofollow">http://kbcmdba.blogspot.com/2009/01/easy-editing-with-mysql-command-line.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parvesh Garg</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-324903</link>
		<dc:creator>Parvesh Garg</dc:creator>
		<pubDate>Tue, 08 Jul 2008 16:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-324903</guid>
		<description>Check my post http://optimmysql.blogspot.com/2008/07/mysql-command-line-pager-mysmartpager.html for a small hack that can do regex based paging.</description>
		<content:encoded><![CDATA[<p>Check my post <a href="http://optimmysql.blogspot.com/2008/07/mysql-command-line-pager-mysmartpager.html" rel="nofollow">http://optimmysql.blogspot.com/2008/07/mysql-command-line-pager-mysmartpager.html</a> for a small hack that can do regex based paging.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javier TacÃ³n</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317552</link>
		<dc:creator>Javier TacÃ³n</dc:creator>
		<pubDate>Wed, 25 Jun 2008 09:59:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317552</guid>
		<description>pager less -niSFX</description>
		<content:encoded><![CDATA[<p>pager less -niSFX</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Lowe</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317405</link>
		<dc:creator>Ryan Lowe</dc:creator>
		<pubDate>Wed, 25 Jun 2008 04:35:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317405</guid>
		<description>gah.  The scrubber changed:

while ( my $line = &lt;STDIN&gt;)

to

while ( my $line = )</description>
		<content:encoded><![CDATA[<p>gah.  The scrubber changed:</p>
<p>while ( my $line = &lt;STDIN&gt;)</p>
<p>to</p>
<p>while ( my $line = )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Lowe</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317404</link>
		<dc:creator>Ryan Lowe</dc:creator>
		<pubDate>Wed, 25 Jun 2008 04:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317404</guid>
		<description>I use pager for two things:

1) Save the results of the last query
2) Replace EXPLAIN with mk-visual-explain

Unfortunately, MySQL 5.0.51a and earlier writes to the tee file AFTER the pager has completed (and to .mysql_history only after you exit mysql), so getting the last command is impossible via these methods (however, it works if you are willing to issue queries twice ...).  You *can* still override commands (EXPLAIN, for example) by having scripts that error if the input does not conform to a standard; an example follows:

#!/usr/bin/perl

use strict;
use warnings FATAL =&gt; &#039;all&#039;;
use English qw ( -no_match_vars );

my $out;

while ( my $line =  ) {

$out .= $line;

}

# Log results to a file (always useful)
# But only ever save one :)
open (PAGER_LOG, &#039;&gt;/tmp/mysql_pager.log&#039;);
print PAGER_LOG &quot;$out\n&quot;;
close (PAGER_LOG);

# See if it an EXPLAIN
eval { local $SIG{&#039;__WARN__&#039;}; system(&#039;/usr/local/bin/mk-visual-explain /tmp/mysql_pager.log 2&gt; /dev/null&#039;); };

if ($?) {

  print $out;

}</description>
		<content:encoded><![CDATA[<p>I use pager for two things:</p>
<p>1) Save the results of the last query<br />
2) Replace EXPLAIN with mk-visual-explain</p>
<p>Unfortunately, MySQL 5.0.51a and earlier writes to the tee file AFTER the pager has completed (and to .mysql_history only after you exit mysql), so getting the last command is impossible via these methods (however, it works if you are willing to issue queries twice &#8230;).  You *can* still override commands (EXPLAIN, for example) by having scripts that error if the input does not conform to a standard; an example follows:</p>
<p>#!/usr/bin/perl</p>
<p>use strict;<br />
use warnings FATAL =&gt; &#8216;all&#8217;;<br />
use English qw ( -no_match_vars );</p>
<p>my $out;</p>
<p>while ( my $line =  ) {</p>
<p>$out .= $line;</p>
<p>}</p>
<p># Log results to a file (always useful)<br />
# But only ever save one <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
open (PAGER_LOG, &#8216;&gt;/tmp/mysql_pager.log&#8217;);<br />
print PAGER_LOG &#8220;$out\n&#8221;;<br />
close (PAGER_LOG);</p>
<p># See if it an EXPLAIN<br />
eval { local $SIG{&#8216;__WARN__&#8217;}; system(&#8216;/usr/local/bin/mk-visual-explain /tmp/mysql_pager.log 2&gt; /dev/null&#8217;); };</p>
<p>if ($?) {</p>
<p>  print $out;</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clint Byrum</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317309</link>
		<dc:creator>Clint Byrum</dc:creator>
		<pubDate>Tue, 24 Jun 2008 23:39:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317309</guid>
		<description>Parvesh, you can have your cake and eat it too.

superpager.bash:


#!/bin/bash
teefile=~/.mysqltee

goback=100

# find the last ^mysql&gt;

lastcmd=$(tail -n $goback $teefile &#124; grep &quot;^mysql&gt; &quot;&#124;tail -1&#124; awk -F&quot;mysql&gt; &quot; &#039;{print $2}&#039;&#124;sed -e &#039;s/\*/\\*/g&#039;)

echo lastcmd=$lastcmd

if echo &quot;$lastcmd&quot; &#124; egrep -qi &quot;^\s*explain&quot; ; then
  exec mk-visual-explain
fi
if echo &quot;$lastcmd&quot; &#124; egrep -qi &quot;^\s*show\s+engine&quot; ; then
  fgrep -C3 -i &quot;LOCK&quot; &#124; less
  exit
fi
less

One has to do a \T ~/.mysqltee before the \P superpager.bash , but thats nice because everything you do gets logged..

Works reasonably well for something I hacked together with bash in 10 minutes. Would be nice if the pager could be passed args like &quot;last command&quot; but this is a decent enough hack until they implement that in version 6.1 of mysql. ;)</description>
		<content:encoded><![CDATA[<p>Parvesh, you can have your cake and eat it too.</p>
<p>superpager.bash:</p>
<p>#!/bin/bash<br />
teefile=~/.mysqltee</p>
<p>goback=100</p>
<p># find the last ^mysql&gt;</p>
<p>lastcmd=$(tail -n $goback $teefile | grep &#8220;^mysql&gt; &#8220;|tail -1| awk -F&#8221;mysql&gt; &#8221; &#8216;{print $2}&#8217;|sed -e &#8216;s/\*/\\*/g&#8217;)</p>
<p>echo lastcmd=$lastcmd</p>
<p>if echo &#8220;$lastcmd&#8221; | egrep -qi &#8220;^\s*explain&#8221; ; then<br />
  exec mk-visual-explain<br />
fi<br />
if echo &#8220;$lastcmd&#8221; | egrep -qi &#8220;^\s*show\s+engine&#8221; ; then<br />
  fgrep -C3 -i &#8220;LOCK&#8221; | less<br />
  exit<br />
fi<br />
less</p>
<p>One has to do a \T ~/.mysqltee before the \P superpager.bash , but thats nice because everything you do gets logged..</p>
<p>Works reasonably well for something I hacked together with bash in 10 minutes. Would be nice if the pager could be passed args like &#8220;last command&#8221; but this is a decent enough hack until they implement that in version 6.1 of mysql. <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PaulM</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317049</link>
		<dc:creator>PaulM</dc:creator>
		<pubDate>Tue, 24 Jun 2008 11:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317049</guid>
		<description>This is one I use a bit, requires a Unix/Linux OS though. You could do similar on MySQL on Windows.

pager grep -v &quot;Sleep&quot; &#124;sort -n -t &quot;&#124;&quot; -k 7 &#124;tail

show processlist will now suppress sleeping sessions and display the top 10 oldest sessions.

Thanks for the tip on passing any script... very nice. I have interesting tests to try out... or just use mytop eh?

Have Fun

Paul</description>
		<content:encoded><![CDATA[<p>This is one I use a bit, requires a Unix/Linux OS though. You could do similar on MySQL on Windows.</p>
<p>pager grep -v &#8220;Sleep&#8221; |sort -n -t &#8220;|&#8221; -k 7 |tail</p>
<p>show processlist will now suppress sleeping sessions and display the top 10 oldest sessions.</p>
<p>Thanks for the tip on passing any script&#8230; very nice. I have interesting tests to try out&#8230; or just use mytop eh?</p>
<p>Have Fun</p>
<p>Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parvesh Garg</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-317033</link>
		<dc:creator>Parvesh Garg</dc:creator>
		<pubDate>Tue, 24 Jun 2008 09:42:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-317033</guid>
		<description>This is cool. I have known (and ignored) this earlier, my bad. But something with mk-visual-explain (one of my favorite tools) is just great.

Next, I would like to see some regex based piping that I can specify in my.cnf, something like 

pager ^explain = mk-visual-explain
pager ^show engine = less
pager .* = stdout 

I dont think I&#039;m asking too much :)

--
Parvesh</description>
		<content:encoded><![CDATA[<p>This is cool. I have known (and ignored) this earlier, my bad. But something with mk-visual-explain (one of my favorite tools) is just great.</p>
<p>Next, I would like to see some regex based piping that I can specify in my.cnf, something like </p>
<p>pager ^explain = mk-visual-explain<br />
pager ^show engine = less<br />
pager .* = stdout </p>
<p>I dont think I&#8217;m asking too much <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;<br />
Parvesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giuseppe Maxia</title>
		<link>http://www.mysqlperformanceblog.com/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/comment-page-1/#comment-316993</link>
		<dc:creator>Giuseppe Maxia</dc:creator>
		<pubDate>Tue, 24 Jun 2008 05:38:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=420#comment-316993</guid>
		<description>Cool tricks. My most frequent usage of &quot;pager&quot; is &quot;vim -&quot; and then manipulate the output at will.

I have a handy script that gives me the size of indexes in a database from a SHOW TABLE STATUS. (Useful when you need to calculate how much memory to allocate for a buffer).

$ cat index_size.sh 
perl -lane &#039;$i+= $F[17];END{print $i}&#039; 

mysql&gt; pager ./index_size.sh
PAGER set to &#039;./index_size.sh&#039;
mysql&gt; show table status;
71680

mysql&gt; nopager


Giuseppe</description>
		<content:encoded><![CDATA[<p>Cool tricks. My most frequent usage of &#8220;pager&#8221; is &#8220;vim -&#8221; and then manipulate the output at will.</p>
<p>I have a handy script that gives me the size of indexes in a database from a SHOW TABLE STATUS. (Useful when you need to calculate how much memory to allocate for a buffer).</p>
<p>$ cat index_size.sh<br />
perl -lane &#8216;$i+= $F[17];END{print $i}&#8217; </p>
<p>mysql&gt; pager ./index_size.sh<br />
PAGER set to &#8216;./index_size.sh&#8217;<br />
mysql&gt; show table status;<br />
71680</p>
<p>mysql&gt; nopager</p>
<p>Giuseppe</p>
]]></content:encoded>
	</item>
</channel>
</rss>

