dbslower(8)

๐Ÿ“ฆ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

๐Ÿ’– dbslower(8) ๐Ÿ’–

System Manager's Manual โœจ okay bestie, this is the manual page for dbslower, so let's get into it ๐Ÿซถ


โœจ NAME โœจ

okay so dbslower is the tool that traces MySQL and PostgreSQL server queries that are slower than a threshold ๐Ÿข It's giving detective ๐Ÿ•ต๏ธโ€โ™€๏ธ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

dbslower [-v] [-p PID [PID ...]] [-x PATH] [-m THRESHOLD]
{mysql,postgres}

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so this traces queries served by a MySQL or PostgreSQL server and prints the ones that go over a latency (query time) threshold โฑ๏ธ by default the threshold is 1 ms, so anything slower than that shows up ๐Ÿ‘€

this uses User Statically-Defined Tracing (USDT) probes, which MySQL and PostgreSQL added for DTrace support ๐Ÿฆ‹ BUT these probes might not be turned on for your installation, so check the REQUIREMENTS section first ๐Ÿ™ˆ if you're on MySQL, you can still trace queries without USDT using the -x option โœจ

โš ๏ธ since this uses BPF, only the root user can use this tool. no root, no dbslower, sorry bestie ๐Ÿ’€

๐Ÿ“‹ REQUIREMENTS ๐Ÿ“‹

you'll need CONFIG_BPF, bcc, and either:

  • a MySQL server with USDT probe support (set when configuring the build with -DENABLE_DTRACE=1) ๐Ÿฌ
  • or a PostgreSQL server with USDT probe support (set when configuring the build with --enable-dtrace) ๐Ÿ˜

๐ŸŒธ OPTIONS ๐ŸŒธ

  • -h โ€” okay this one just prints the usage message ๐Ÿ’Œ
  • -p PID โ€” traces this PID ๐ŸŽฏ if you don't give a PID, the tool tries to auto-detect the MySQL or PostgreSQL processes running on the system, so it does the work for you ๐Ÿงš
  • -x PATH โ€” the path to the MySQL binary ๐Ÿช„ this lets you trace MySQL queries even when USDT probes aren't enabled on the MySQL server, which is so clutch ๐Ÿซถ
  • -m THRESHOLD โ€” the minimum query latency (duration) to trace, in milliseconds โฑ๏ธ the default is 1 ms ๐Ÿ’–
  • {mysql,postgres} โ€” the database engine you want to trace ๐Ÿฌ๐Ÿ˜

๐Ÿ“ EXAMPLES ๐Ÿ“

trace MySQL server queries slower than 1 ms:

# dbslower mysql

trace queries slower than 10 ms for PostgreSQL in process 408:

# dbslower postgres -p 408 -m 10

๐Ÿฆ‹ FIELDS ๐Ÿฆ‹

  • TIME(s) โ€” when the query started, in seconds โฐ
  • PID โ€” process ID of the traced server ๐Ÿ†”
  • MS โ€” how many milliseconds the query took, from start to end ๐Ÿ•
  • QUERY โ€” the query string, truncated to 256 characters โœ‚๏ธ

๐ŸŒˆ OVERHEAD ๐ŸŒˆ

this adds low-overhead instrumentation to queries, and it only sends output data from the kernel up to user level if a query goes over the threshold ๐Ÿง  if the server's query rate is less than 1,000/sec, the overhead is expected to be negligible ๐Ÿ˜Œ if the query rate is higher, test it out to gauge the overhead yourself ๐Ÿ”ฅ


๐Ÿ”— 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 ๐Ÿ“–โœจ


๐Ÿ–ฅ๏ธ OS ๐Ÿ–ฅ๏ธ

Linux ๐Ÿง


๐Ÿšง STABILITY ๐Ÿšง

Unstable - in development. so it's still a work in progress, bestie ๐Ÿ› ๏ธ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Sasha Goldshtein, Brendan Gregg ๐Ÿซถ


๐Ÿ”ฎ SEE ALSO ๐Ÿ”ฎ

biosnoop(8), mysqld_qslower(8), dbstat(8) ๐Ÿ’œ


okay that's the whole tea โ˜•๐Ÿ’– this page is from the USER COMMANDS section, dated 2017-02-15, and it's all about dbslower(8) ๐ŸŽ€ stay hydrated, stay root, and go trace those slow queries bestie ๐Ÿ’…๐ŸŒธ