mysqld_qslower(8)

πŸ“¦ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

✨ mysqld_qslower(8) ✨

System Manager's Manual πŸŽ€

πŸ’– NAME πŸ’–

mysqld_qslower β€” traces MySQL server queries that are slower than a threshold πŸ¦‹

🧚 SYNOPSIS 🧚

mysqld_qslower PID [min_ms]

πŸ“– DESCRIPTION πŸ“–

okay so this traces the queries a MySQL server is serving and only prints the ones that go over a latency (aka query duration) threshold you pick πŸ‘€βœ¨ by default the minimum is 1 millisecond. if you set the threshold to 0, literally every query gets printed πŸ’€

this one uses User Statically-Defined Tracing (USDT) probes, which MySQL added for DTrace support. ngl that feature might not be switched on for your MySQL install, so check the requirements section πŸ™ˆ

also, since this tool runs on BPF, only the root user can use it πŸ”₯ no cap, bring your root energy or it's a no 😭

πŸŽ€ REQUIREMENTS πŸŽ€

you'll need CONFIG_BPF, bcc, and a MySQL server built with USDT probe support. that last one is set when you configure the build with -DENABLE_DTRACE=1 πŸ’…

⭐ OPTIONS ⭐

  • PID β€” the mysqld process ID you want to trace 🌸
  • min_ms β€” the minimum query latency (duration) to trace, in milliseconds. it defaults to 1 ms if you don't pass it πŸ“

🌈 EXAMPLES 🌈

trace MySQL server queries slower than 1 ms for PID 1981 πŸ¦‹

# mysqld_qslower 1981

trace anything slower than 10 ms for PID 1981 ✨

# mysqld_qslower 1981 10

πŸ’œ FIELDS πŸ’œ

the output has four columns, bestie:

  • TIME(s) β€” when the query started, in seconds ⏰
  • PID β€” the process ID of the traced server 🫢
  • MS β€” how many milliseconds the query took, from start to end πŸ”₯
  • QUERY β€” the query string, cut off at 128 characters βœ‚οΈ

πŸ¦‹ OVERHEAD πŸ¦‹

this adds low-overhead instrumentation to MySQL queries, and it only pushes data from the kernel up to user level when a query goes over the threshold, which is so smart 🧠 if the server handles less than 1,000/sec, the overhead should be negligible πŸ’– if your query rate is higher, go test it and see what the overhead looks like for you πŸ™ˆ

πŸ“ SOURCE πŸ“

this comes from bcc 🫢

https://github.com/iovisor/bcc

also look in the bcc distribution for a companion _examples.txt file. it has example usage, output, and commentary for this tool, and it's giving very helpful notes ✨

🌸 OS 🌸

Linux 🐧

πŸ§ͺ STABILITY πŸ§ͺ

Unstable - in development. so it's still cooking 🍳

πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg πŸ’…

πŸ”— SEE ALSO πŸ”—

biosnoop(8) πŸ¦‹


bestie, that's the whole page! πŸ’œ this is the USER COMMANDS manual, dated 2016-08-01, for mysqld_qslower(8) πŸŽ€ stay curious and keep those queries fast 🌈✨