免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1894 | 回复: 0
打印 上一主题 下一主题

mysql中pager的用法 [复制链接]

论坛徽章:
9
每日论坛发贴之星
日期:2016-01-04 06:20:00数据库技术版块每日发帖之星
日期:2016-01-04 06:20:00每日论坛发贴之星
日期:2016-01-04 06:20:00数据库技术版块每日发帖之星
日期:2016-01-04 06:20:00IT运维版块每日发帖之星
日期:2016-01-04 06:20:00IT运维版块每日发帖之星
日期:2016-01-04 06:20:00综合交流区版块每日发帖之星
日期:2016-01-04 06:20:00综合交流区版块每日发帖之星
日期:2016-01-04 06:20:00数据库技术版块每周发帖之星
日期:2016-03-07 16:30:25
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-03 19:35 |只看该作者 |倒序浏览

                Over the past few years I have found that "pager" inside of MySQL is a
really useful tool. I have come up with a few simple, but extremely
effective, ways to use it.

-- Example 1

Lets say you have a MySQL server that is really busy with extremely
long queries. You run a “show full processlist” and everything going on
streams before your eyes, new lines and all. A more readable way to see
what is going on is…
Mysql> pager less –S
By running the above statement the full processlist will NOT appear in
the traditional, word wrapped format. The output will show in a very
readable, right extended, format. All you need to do now figure out
what is going on.
Here is a helpful hint. Set a tee file for MySQL client output.
Mysql> \T /location/to/file.txt
Then, make sure pager is set to “less –S”. From there you can get out
of the MySQL client and write a shell script to sort or do whatever to
the file.

-- Example 2

Lets say you’re the DBA that is responsible to ensure that all of NEW
MySQL SQL statement are functionally equivalent. Or, lets say that you
are responsible for optimizing NEW SQL and to ensure that is hold
integrity from the old version to the new version. You might say, “is
an easy way to tell if you have an exact data set match or not?’ Well,
yeppers, there is! All you need to do is use “pager”.
Mysql> pager md5sum
Then run the OLD SQL statement, gather the md5sum, then run the NEW and
improved SQL and gather the md5sum. If both are the same then both
datasets returned in either SQL statement are exact. Below is an
example with the world database, just to illustrate the point.
mysql> select * from City as c, Country ct where c.countrycode = ct.code;
3c8c6b8331c9270f8565edd1a8b8d7a5 -
4079 rows in set (0.05 sec)
mysql> select * from City c join Country ct ON(c.countrycode = ct.code);
3c8c6b8331c9270f8565edd1a8b8d7a5 -
4079 rows in set (0.05 sec)
These are just a couple cool ways to use “pager” inside of the MySQL
client. Oh, and before I forget, to turn pager off inside the MySQL
command line run the following:
Mysql> nopager
Or just log out and log back in.
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/90603/showart_2063757.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP