Database performance analyzer for PostgreSQL, MySQL, and MariaDB. Monitor slow queries, visualize EXPLAIN plans, and track index usage — all from a single binary.
Documentation: dbsight.khuong.dev
- Slow Query Detection — polls
pg_stat_statements(PostgreSQL),performance_schema(MySQL/MariaDB) every 30s, ranks by total execution time with delta tracking - Live Dashboard — real-time updates via Server-Sent Events (SSE), no page refresh needed
- EXPLAIN Plans — run EXPLAIN safely with per-database format support (PostgreSQL JSON, MySQL FORMAT=JSON, MariaDB ANALYZE FORMAT=JSON)
- Index Analysis — identify unused indexes and missing index opportunities
- Paste Mode — analyze slow query logs offline without a live database connection
- Multi-Database — monitor multiple PostgreSQL, MySQL, and MariaDB instances from one dashboard
- Secure — DSN credentials encrypted with AES-256-GCM, never exposed via API
- Go 1.26+
- Node.js 20+
- One or more supported databases:
- PostgreSQL 14+ (with
pg_stat_statementsextension enabled) - MySQL 5.7+ or 8.0+ (with
performance_schemaenabled) - MariaDB 10.x+ (with
performance_schemaenabled)
- PostgreSQL 14+ (with
- Docker & Docker Compose (optional)
docker-compose up -d postgres# Generate a 32-byte encryption key
export ENCRYPTION_KEY=$(openssl rand -hex 32)
# Configure database
export DATABASE_URL="postgres://dbsight:secret@localhost:5499/dbsight?sslmode=disable"
# Run migrations
go run . migrate
# Start the server (API + worker)
go run . servepnpm install # Install all workspace dependencies
pnpm --filter web dev # Vite dev server on :5173, proxies /api to :42198pnpm --filter docs dev # Starlight dev server on :4321
pnpm --filter docs build # Build static docs sitemake build # Builds frontend, then Go binary → bin/dbsight
./bin/dbsight serveOr with Docker:
make docker-build
docker run -e DATABASE_URL=... -e ENCRYPTION_KEY=... -p 42198:42198 dbsight:latestThis is a pnpm workspaces monorepo:
dbsight/
├── apps/web/ # React SPA (Vite + shadcn/ui)
├── apps/docs/ # Starlight documentation site (EN + VI)
├── internal/ # Go backend packages
├── migrations/ # SQL migration files
├── main.go # Entry point — embeds apps/web/dist into binary
└── docker-compose.yml
┌─────────────────────────────────────────────┐
│ Go Binary (dbsight) │
│ │
│ ┌──────────┐ ┌────────┐ ┌────────────┐ │
│ │ Chi API │ │ Worker │ │ Embedded │ │
│ │ Server │ │ (30s) │ │ React SPA │ │
│ └────┬─────┘ └───┬────┘ └────────────┘ │
│ │ │ │
│ ┌────┴────────────┴──────┐ │
│ │ Store (pgxpool) │ │
│ └────────────┬───────────┘ │
└───────────────┼─────────────────────────────┘
│
┌───────┴───────┐
│ PostgreSQL │ (app metadata + metrics)
└───────────────┘
│
┌───────┴───────┐
│ Target DBs │ (via DBAnalyzer adapter)
└───────────────┘
The single binary serves the API, background worker, and React SPA. The worker collects metrics from target databases via the adapter interface — extensible to MySQL and others.
| Layer | Technology |
|---|---|
| Backend | Go 1.26+, Chi router, pgx/v5, Cobra CLI |
| Frontend | React 19, Vite, TypeScript, shadcn/ui, Tailwind CSS v4 |
| Data | TanStack Table v8, Recharts |
| Database | PostgreSQL (metadata storage) |
| Security | AES-256-GCM encrypted DSN storage |
| Real-time | Server-Sent Events (SSE) |
| Deploy | Docker multi-stage build |
| Docs | Astro Starlight, i18n (EN + VI), Pagefind search |
| Variable | Default | Description |
|---|---|---|
PORT |
42198 |
HTTP server port |
DATABASE_URL |
— | PostgreSQL connection string for app DB |
ENCRYPTION_KEY |
— | 64 hex chars (32 bytes) for AES-256-GCM |
WORKER_INTERVAL_SECS |
30 |
Metrics polling interval in seconds |
Enable pg_stat_statements on the databases you want to monitor:
-- postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
-- Then run:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;Ensure performance_schema is enabled (usually on by default):
-- Check if it is enabled
SHOW GLOBAL VARIABLES LIKE 'performance_schema';
-- Should return 'ON'
-- If disabled, add to my.cnf and restart:
[mysqld]
performance_schema = ONEnable performance_schema in the configuration:
-- Check if it is enabled
SHOW GLOBAL VARIABLES LIKE 'performance_schema';
-- Should return 'ON'
-- If disabled, add to my.cnf and restart:
[mysqld]
performance_schema = ON| Method | Endpoint | Description |
|---|---|---|
| GET/POST | /api/connections |
List / create connections |
| GET/PUT/DELETE | /api/connections/{id} |
Get / update / delete connection |
| POST | /api/connections/{id}/test |
Test connection (returns latency) |
| GET | /api/connections/{id}/queries |
Latest slow queries with deltas |
| GET | /api/connections/{id}/queries/stream |
SSE live query updates |
| GET | /api/connections/{id}/queries/history |
Historical snapshots |
| POST | /api/paste/queries |
Parse slow query log text |
- Project scaffold + config
- Database schema + store layer
- DB adapter interface + PostgreSQL implementation
- API server + connection management
- Background worker + query endpoints
- React frontend foundation
- Slow query dashboard UI
- EXPLAIN plan visualization (custom tree renderer)
- Index analysis dashboard
- Docker production deployment
- Monorepo restructure (pnpm workspaces)
- Documentation site (Starlight, EN + VI)
MIT