Databases

From DTraceBook

Jump to: navigation, search

This chapter uses DTrace for analyzing the MySQL, PostgreSQL and Oracle databases.

Contents

Sample One-Liners

See the DTrace book for more one-liners.

MySQL

MySQL: query trace by query string:
dtrace -n 'mysql*:::query-start { trace(copyinstr(arg0)) }'

MySQL: query count summary by host:
dtrace -n 'mysql*:::query-start { @[copyinstr(arg4)] = count(); }'

MySQL server: trace queries:
dtrace -qn 'pid$target::*mysql_parse*:entry { printf("%Y %s\n", walltimestamp, copyinstr(arg1)); }' -p PID

MySQL client: who's doing what (stack trace by query):
dtrace -Zn 'pid$target:libmysql*:mysql_*query:entry { trace(copyinstr(arg1)); ustack(); }' -p PID

PostgreSQL

PostgreSQL: query trace by query string:
dtrace -n 'postgresql*:::query-start { trace(copyinstr(arg0)) }'

PostgreSQL: query count summary by query string:
dtrace -n 'postgresql*:::query-start { @[copyinstr(arg0)] = count(); }'

PostgreSQL server: count queries:
dtrace -n 'pid$target::exec_simple_query:entry { @[copyinstr(arg0)] = count(); }' -p PID

Scripts

Errata

Links

Personal tools