mysql中pager的用法
来源:互联网 发布:1024最新 知乎 编辑:程序博客网 时间:2024/05/01 05:59
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.
-- 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.
- mysql中pager的用法
- mysql中pager命令的妙用
- mysql中pager命令的妙用
- mysql中pager命令的妙用
- mysql中pager命令妙用
- AspNet pager 分页的基本用法
- pager-taglib.jar分页的用法
- Mysql tee prompt pager
- mysql grep pager
- pager-taglib -- 分页标签用法
- Java中 分页组件Pager-taglib的使用
- MySQL中limit的用法
- Mysql中show的用法
- Mysql中limit的用法
- mysql中find_in_set的用法
- mysql中limit的用法
- MySQL中show的用法
- mysql 中explain的用法
- HWND and HDC 以及 DC 释放问题
- 教你怎么看top命令-linux进度
- 关于两种运行sh的方式: ./myscript.ksh and . ./myscript.ksh
- shopex二次开发手册
- awk输出到多个文件
- mysql中pager的用法
- 利用opencv逼近二值图像的边界点,并过滤不需要的边界,达到寻边效果。(转载请说明出处)
- Oracle 开发常见问题
- Emacs 新闻组 之三 收发Gmail
- android入门-------案例七(alertdialog的使用)
- 凝聚力
- spring的HibernateDaoSupport以及HibernateTemplate和jdbcTemplate的选择问题
- Spring 解决线程中无法获得数据库连接
- spring