From your mysql prompt change your pager by issuing the likes of;
Step through the INNODB STATUS output
mysql> pager more
mysql> SHOW ENGINE INNODB STATUS \G
...
mysql> SHOW ENGINE INNODB STATUS \G
...
grep-ing your output;
Sleeping Connections
mysql> pager grep -i sleep
PAGER set to 'grep -i sleep'
mysql> show processlist;
| 152 | squeezecenter | localhost | squeezecenter | Sleep | 36 | | NULL |
3 rows in set (0.02 sec)
PAGER set to 'grep -i sleep'
mysql> show processlist;
| 152 | squeezecenter | localhost | squeezecenter | Sleep | 36 | | NULL |
3 rows in set (0.02 sec)
Grouping variables/status counters together for easy eye-balling
mysql> pager grep -i 'key'
PAGER set to 'grep -i key'
mysql> SHOW GLOBAL STATUS;
| Com_assign_to_keycache | 0 |
| Com_preload_keys | 0 |
| Com_show_keys | 0 |
| Handler_read_key | 611 |
| Key_blocks_not_flushed | 0 |
| Key_blocks_unused | 14343 |
| Key_blocks_used | 10 |
| Key_read_requests | 4197 |
| Key_reads | 13 |
| Key_write_requests | 144 |
| Key_writes | 140 |
291 rows in set (0.03 sec)
PAGER set to 'grep -i key'
mysql> SHOW GLOBAL STATUS;
| Com_assign_to_keycache | 0 |
| Com_preload_keys | 0 |
| Com_show_keys | 0 |
| Handler_read_key | 611 |
| Key_blocks_not_flushed | 0 |
| Key_blocks_unused | 14343 |
| Key_blocks_used | 10 |
| Key_read_requests | 4197 |
| Key_reads | 13 |
| Key_write_requests | 144 |
| Key_writes | 140 |
291 rows in set (0.03 sec)
There is the potential to do some really cool things with this;
Using Maatkit/Percona toolkit or custom scripts
mysql> pager mk-visual-explain
PAGER set to 'mk-visual-explain'
mysql> EXPLAIN select a.title, c.name from albums a join contributors c on a.contributor = c.id where c.name LIKE '%Monkeys%';
JOIN
+- Filter with WHERE
| +- Bookmark lookup
| +- Table
| | table c
| | possible_keys PRIMARY
| +- Unique index lookup
| key c->PRIMARY
| possible_keys PRIMARY
| key_len 4
| ref db.a.contributor
| rows 1
+- Table scan
rows 483
+- Table
table a
2 rows in set (0.00 sec)
PAGER set to 'mk-visual-explain'
mysql> EXPLAIN select a.title, c.name from albums a join contributors c on a.contributor = c.id where c.name LIKE '%Monkeys%';
JOIN
+- Filter with WHERE
| +- Bookmark lookup
| +- Table
| | table c
| | possible_keys PRIMARY
| +- Unique index lookup
| key c->PRIMARY
| possible_keys PRIMARY
| key_len 4
| ref db.a.contributor
| rows 1
+- Table scan
rows 483
+- Table
table a
2 rows in set (0.00 sec)
Don't forget to revert to normal;
mysql> nopager
PAGER set to stdout
PAGER set to stdout

No comments:
Post a Comment