SQL Flamegraph is a powerful visualization tool for analyzing and optimizing MySQL query execution plans. It transforms MySQL's EXPLAIN ANALYZE output into intuitive flame graphs, helping developers and database administrators better understand and optimize query performance.
- Convert MySQL EXPLAIN ANALYZE output into interactive flame graphs
- User-friendly web interface
- RESTful API support
- Automatic query history tracking
- Docker deployment support
- Python 3.7+
- MySQL 8.0+
- Perl (for flame graph generation)
- Clone the repository:
git clone https://github.com/kevinbin/sqlflamegraph.git
cd sqlflamegraph
- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Set up MySQL:
mysql -u your_username -p < init.sql
- Clone the repository:
git clone https://github.com/kevinbin/sqlflamegraph.git
cd sqlflamegraph
- Create a
.env
file (optional):
MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_USER=your_user
MYSQL_PASSWORD=your_password
- Start the services:
docker-compose up -d
The application will be available at http://localhost:8000
To stop the services:
docker-compose down
To stop the services and remove all data:
docker-compose down -v
- Start the service:
python mysqlflamegraph.py # for direct installation
# or
docker-compose up -d # for docker installation
-
Access the web interface: Open your browser and visit http://localhost:8000
-
Get query execution plan from MySQL:
EXPLAIN ANALYZE SELECT * FROM your_table WHERE ...;
- Paste the execution plan output into the web interface to generate the flame graph
curl -X POST http://localhost:8000/api/sqlflamegraph \
-H "Content-Type: application/json" \
-d '{"explain": "your EXPLAIN ANALYZE output here"}'
Returns an SVG flame graph that can be viewed in any modern web browser.
MYSQL_HOST
: MySQL server hostname (default: localhost)MYSQL_USER
: MySQL usernameMYSQL_PASSWORD
: MySQL passwordMYSQL_DATABASE
: MySQL database name (default: sqlflamegraph)MYSQL_PORT
: MySQL port (default: 3306)MYSQL_ROOT_PASSWORD
: MySQL root password (Docker only)
Pull requests and issues are welcome!
MIT License
- Brendan Gregg's FlameGraph - Flame graph generation tool
- FastAPI - Web framework