dbstat(8)

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

πŸ’– dbstat(8) πŸ’–

System Manager's Manual πŸŽ€

✨ NAME ✨

okay so dbstat is the tool that collects histograms of MySQL/PostgreSQL query latencies πŸ“Š bestie, this one is lowkey iconic πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

dbstat [-v] [-p PID [PID ...]] [-m THRESHOLD] [-u] [-i INTERVAL]
{mysql,postgres}

🌸 DESCRIPTION 🌸

So this traces queries served by a MySQL or PostgreSQL server and builds a histogram of query latencies πŸ”₯ The histogram gets printed when collection ends, or at whatever intervals you ask for.

It uses User Statically-Defined Tracing (USDT) probes, which MySQL and PostgreSQL added for DTrace support. Those probes might not be enabled on your installation though, so see REQUIREMENTS πŸ™ˆ

Since this uses BPF, only the root user can use this tool. No root, no dbstat, periodt πŸ’€

πŸŽ€ REQUIREMENTS πŸŽ€

You need CONFIG_BPF, bcc, and either:

  • A MySQL server with USDT probe support, which means configuring the build with -DENABLE_DTRACE=1
  • A PostgreSQL server with USDT probe support, which means configuring the build with --enable-dtrace

πŸ’… OPTIONS πŸ’…

  • -h β€” prints the usage message 🫢
  • -p PID β€” traces this PID. If you don't give one, the tool tries to automatically find the MySQL or PostgreSQL processes running on the system ✨
  • -m THRESHOLD β€” the minimum query latency (duration) to trace, in milliseconds. The default is all queries 🧚
  • -u β€” shows query latencies in microseconds instead of the default milliseconds 🌈
  • -i INTERVAL β€” prints summaries (histograms) at this interval, in seconds ⏰
  • {mysql,postgres} β€” the database engine you want to trace πŸ“

🧁 EXAMPLES 🧁

Display a histogram of MySQL query latencies:

# dbstat mysql

Display a histogram of PostgreSQL query latencies slower than 10ms in pid 408:

# dbstat postgres -p 408 -m 10

Display a histogram of PostgreSQL query latencies at 3-second intervals:

# dbstat postgres -i 3

πŸŒ™ OVERHEAD πŸŒ™

Okay the vibe here is low-overhead ✨ It adds lightweight instrumentation to queries, and only sends output data from the kernel to user level if a query exceeds the threshold. If the server query rate is less than 1,000/sec, the overhead is expected to be negligible. If the query rate is higher, test it to gauge the overhead πŸ“ˆ

πŸ“¦ SOURCE πŸ“¦

This is from bcc πŸ¦‹

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file, which has example usage, output, and commentary for this tool πŸ“š

πŸ’» OS πŸ’»

Linux only, bestie 🐧

🚧 STABILITY 🚧

Unstable - in development. Use with care, it's still cooking 🍳

πŸ‘©β€πŸ’» AUTHOR πŸ‘©β€πŸ’»

Sasha Goldshtein, the main character behind this one πŸ‘‘

πŸ”— SEE ALSO πŸ”—

dbslower(8) is the one to check out next πŸ’œ


Sourced from bcc, OS Linux, filed under USER COMMANDS and dated 2017-02-15, dbstat(8) is giving old-school reliable energy πŸ«ΆπŸ’–