zoukankan      html  css  js  c++  java
  • pager 命令

    Last time I wrote about a few tips that can make you more efficient when using the command line on Unix. Today I want to focus more on pager.

    The most common usage of pager is to set it to a Unix pager such as less. It can be very useful to view the result of a command spanning over many lines (for instance SHOW ENGINE INNODB STATUS):

    Now you are inside less and you can easily navigate through the result set (use q to quit, space to scroll down, etc).

    Reminder: if you want to leave your custom pager, this is easy, just run pager:

    2. :

    But the pager command is not restricted to such basic usage! You can pass the output of queries to most Unix programs that are able to work on text. We have discussed the topic, but here are a few more examples.

    Discarding the result set

    Sometimes you don’t care about the result set, you only want to see timing information. This can be true if you are trying different execution plans for a query by changing indexes. Discarding the result is possible with pager:

    Comparing result sets

    Let’s say you are rewriting a query and you want to check if the result set is the same before and after rewrite. Unfortunately, it has a lot of rows:

    Instead of manually comparing each row, you can calculate a checksum and only compare the checksum:

    Hmmm, checksums don’t match, something is wrong. Let’s retry:

    Checksums are identical, the rewritten query is much likely to produce the same result as the original one.

    Cleaning up SHOW PROCESSLIST

    If you have lots of connections on your MySQL, it’s very difficult to read the output of SHOW PROCESSLIST. For instance, if you have several hundreds of connections and you want to know how many connections are sleeping, manually counting the rows from the output of SHOW PROCESSLIST is probably not the best solution. With pager, it is straightforward:

    Slightly more complicated now: you want to know the number of connections for each status:

    Astute readers will have noticed that these questions could have been solved by querying INFORMATION_SCHEMA. For instance, counting the number of sleeping connections can be done with:

    True, but:

    • It’s nice to know several ways to get the same result
    • Some of you may feel more comfortable with writing SQL queries, while others will prefer command line tools

     

     
  • 相关阅读:
    SQLServer2008新建链接服务器for Oracle
    提示Can't load package:dclite70.bpl解决方法
    android实现自动升级并安装打开
    【转】Ubuntu 14.04.3上配置并成功编译Android 6.0 r1源码
    Android日志打印类LogUtils,能够定位到类名,方法名以及出现错误的行数并保存日志文件
    Linux 自定义命令
    CentOS时间的查看与修改
    Linux expect自动登录ssh,ftp
    ★Linux命令行操作技巧(作为服务器端)
    ★Linux桌面系统技巧(作为客户端)
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5676968.html
Copyright © 2011-2022 走看看