Tuesday, December 15, 2009

[Level 3] Using DTrace for MySQL DB.

I'm glade to here that, in MySQL 5.4 beta, it supports that to use Solaris DTrace to monitor MySQL SQL statement.


About the probe for MySQL, please refer to the following link:
http://dev.mysql.com/doc/refman/5.4/en/dba-dtrace-mysqld-ref.html

I use one of the scripts to demo the result of DTrace,
http://dev.mysql.com/doc/refman/5.4/en/dba-dtrace-ref-query.html

The result as below:
Sessin 1:
[stanley@Stanley-NB]:/usr/mysql# mysql

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.4.3-beta MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

stanley@localhost:stanley mysql> show tables;
Empty set (0.00 sec)

stanley@localhost:stanley mysql>



Sessin 2:
root@Stanley-NB:/tmp# ./MySQL_query.d

Who                  Database             Query                                    Time(ms)
stanley@localhost    stanley              select @@version_comment limit 1         0       
stanley@localhost    stanley              select USER()                            0       
stanley@localhost    stanley              show tables                              2       


Wish this helps.

regards,
Stanley Huang