dbstat(8)
π 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 π«Άπ
π¦ where this page comes from
- debian bookworm: bpfcc-tools 0.26.0+ds-1 Β· Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 Β· Apache-2.0
- ubuntu jammy: bpfcc-tools 0.18.0+ds-2 Β· Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 Β· Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 Β· Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 Β· Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms