mysql pager 妙用!

喜歡看英文的可以去http://www.mysqlperformanceblog.com/2013/01/21/fun-with-the-mysql-pager-command/

@Stephane Combaudon


分頁顯示。

mysql> pager less

PAGER set to 'less'

mysql> show engine innodb status\G

[...]

退出pager

mysql> pager

Default pager wasn't set, using stdout.

or

mysql> \n

PAGER set to stdout

一些其他的用法

mysql> pager cat > /dev/null

PAGER set to 'cat > /dev/null'

# Trying an execution plan

mysql> show tables;

11 rows in set (0.00 sec)


mysql> select * from t_s;

8 rows in set (0.00 sec)

這個不錯

mysql> select * from t_s;

+---+---+

| a | b |

+---+---+

| 1 | 0 |

| 2 | 0 |

| 3 | 0 |

| 4 | 0 |

| 5 | 0 |

| 6 | 0 |

| 7 | 0 |

| 8 | 1 |

+---+---+

8 rows in set (0.00 sec)

mysql> pager md5sum

PAGER set to 'md5sum'

# Original query

mysql> select * from t_s;

5a75d0e7c3c5af75683e2a8152658b4a  -

8 rows in set (0.00 sec)

mysql> update t_s set b=1 where a=1;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t_s;

f9178450be750a1da67d8046c9658e50  -

8 rows in set (0.00 sec)

上面兩個查詢不一樣了?

mysql> pager grep Sleep | wc -l

PAGER set to 'grep Sleep | wc -l'

mysql> show processlist;

7

8 rows in set (0.00 sec)

mysql> pager awk -F '|' '{print $6}'| sort | uniq -c | sort -r

PAGER set to 'awk -F '|' '{print $6}'| sort | uniq -c | sort -r'

mysql> show processlist;

     9  Sleep  

     3

     1  Query  

     1  Command

10 rows in set (0.00 sec)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章