SQLens is a transparent TCP proxy that intercepts and analyzes SQL queries in real-time. It helps detect N+1 query patterns, slow queries, and provides a live performance dashboard—with zero code changes to your application.
- Transparent Proxy: Just point your app to SQLens instead of your DB.
- N+1 Detection: Automatically flags inefficient ORM patterns.
- Performance Guardrails: Real-time detection of SQL anti-patterns (e.g., SELECT *, missing WHERE).
- Data Privacy: Optional PII redaction mode to mask sensitive query values.
- Slow Query Tracking: Real-time latency measurement and visualization.
- Live Dashboard: Web-based interface to see what's happening under the hood.
-
Clone and Start:
make docker-up
-
Access Dashboard: Open http://localhost:8080
-
Connect your App: Change your DB connection port from
5432to5433.Example psql connection:
psql -h localhost -p 5433 -U user -d demo
- Go 1.23+
- Docker & Docker Compose (optional for local DB)
make build: Compile the binary.make test: Run unit tests.make benchmark: Run a realistic load simulation script.
SQLens can be configured via environment variables:
SQLENS_LISTEN_ADDR: Proxy listen address (default:5433)SQLENS_TARGET_ADDR: Target database address (defaultlocalhost:5432)SQLENS_N1_THRESHOLD: Number of repeated queries to trigger alert (default5)SQLENS_REDACT_SENSITIVE: Enable to mask sensitive data in logs/dashboard (defaultfalse)
Built for SQL performance observability.
