Getting Started
Install myflames, generate your first flame graph, and understand a query plan in under 5 minutes.
Prerequisites
- Python 3.7+ (no extra packages needed)
- MySQL 8.4+ with
EXPLAIN ANALYZE FORMAT=JSONsupport, or - MariaDB 10.11+ / 11.4+ with
ANALYZE FORMAT=JSON
Installation
1
Install from PyPI
pip install myflames
On macOS with PEP 668 restrictions, use pipx:
pipx install myflames
2
Verify the installation
myflames --help
myflames guide # shows which view to use
Your first flame graph (file mode)
1
Capture an EXPLAIN ANALYZE plan
# MySQL 8.4+
mysql -u user -p mydb -s -N -r -e \
"EXPLAIN ANALYZE FORMAT=JSON SELECT * FROM orders WHERE user_id = 1" \
> explain.json
# MariaDB 10.11+
mariadb -u user -p mydb -s -N -r -e \
"ANALYZE FORMAT=JSON SELECT * FROM orders WHERE user_id = 1" \
> explain.json
Use
EXPLAIN ANALYZE (with ANALYZE), not just EXPLAIN. The ANALYZE keyword is required for timing data.
2
Render a flame graph
# SVG to stdout
myflames explain.json > query.svg
# Self-contained HTML report (recommended)
myflames --output report.html explain.json
# Creates: report.html + report.json (machine-readable sidecar)
3
Open in your browser
open report.html # macOS
xdg-open report.html # Linux
The HTML report includes interactive zoom, search (Ctrl+F), tooltips, and a Query Analysis panel with tuning suggestions.
Live connection mode (skip the file)
Connect directly to a running MySQL/MariaDB server using the same flags as the mysql CLI:
myflames -h 127.0.0.1 -u root -p -D mydb \
-e 'SELECT * FROM orders WHERE user_id = 1' \
--output report.html
In live mode, myflames:
- Connects through the real
mysql/mariadbclient binary (supports all auth plugins) - Runs
EXPLAIN ANALYZE FORMAT=JSONfor you - Collects
SHOW CREATE TABLE, row counts, and session variables - Feeds everything through the environment advisor
- Emits an HTML report + JSON sidecar with tuning suggestions
Password security: the password is written to a mode-0600 temporary file and never appears in
ps, env vars, or logs.
TLS connections (e.g., AWS RDS)
myflames -h my-db.rds.amazonaws.com -u admin -p \
--ssl-mode=VERIFY_IDENTITY --ssl-ca=/path/to/global-bundle.pem \
-D prod -e 'SELECT ...' --output report.html
Try other view types
myflames --type bargraph explain.json > bar.svg # slowest ops first
myflames --type treemap explain.json > tree.svg # area = cost
myflames --type diagram explain.json > diag.svg # Visual Explain flow
myflames --type tree explain.json > exec.svg # collapsible tree
See the View Types guide for when to use each one.
Compare before vs after
myflames compare before.json after.json --output diff.html
Shows total time delta, per-operator changes, new/resolved warnings, and new/removed full table scans.
Learn the algorithms
myflames includes 9 interactive lessons that animate MySQL internals with correct cost models:
myflames teach btree -o btree.html && open btree.html
See the full catalog at Teach Lessons.
Next steps
- View Types — when to use each visualization
- CLI Reference — every flag and option
- Architecture — how myflames works internally
- Teach Lessons — animated algorithm walkthroughs