Show HN: SQL-tap – Real-time SQL traffic viewer for PostgreSQL and MySQL
SQL-tap is an ingenious transparent proxy that lets developers view PostgreSQL and MySQL traffic in real-time through a terminal UI. This 'Show HN' project is gaining traction for its ability to capture queries, transactions, and performance metrics, including EXPLAIN plans, without requiring any application code modifications. It addresses a common pain point for database debugging and optimization, making complex introspection surprisingly simple for the technically inclined.
The Lowdown
SQL-tap is presented as a novel tool designed to provide real-time visibility into SQL traffic between applications and PostgreSQL or MySQL databases. It functions as a transparent proxy, intercepting and displaying database queries through an interactive terminal user interface (TUI). This utility aims to simplify debugging and performance analysis by allowing developers to observe database interactions without altering their application code.
- Transparent Proxy: Operates by sitting between the application and the database, parsing the native wire protocol for PostgreSQL and MySQL to capture all SQL queries.
- Real-time TUI: Provides an interactive terminal interface (sql-tap) that displays captured queries, transactions, and associated metadata in real-time, streamed via gRPC from the proxy daemon (sql-tapd).
- No Code Changes: A significant advantage is that it requires no modifications to existing application code; users only need to configure their application to connect to the sql-tapd proxy's port instead of the database's direct port.
- Debugging & Optimization Features:
- Inspect individual queries and transactions.
- Execute EXPLAIN and EXPLAIN ANALYZE on captured queries directly from the TUI to understand execution plans.
- Allows editing queries before running EXPLAIN.
- Tracks prepared statements, parameter bindings, execution times, rows affected, and errors.
- Installation Flexibility: Can be installed via Homebrew, Go, building from source, or using pre-built Docker images for both PostgreSQL and MySQL environments.
- Comprehensive Keybindings: The TUI offers a rich set of keyboard shortcuts for navigation, query inspection, transaction management, and EXPLAIN operations.
SQL-tap offers a powerful and non-intrusive way for developers to gain deep insights into their database interactions, making it a valuable asset for diagnosing performance issues, understanding application behavior, and optimizing SQL queries. Its transparent proxy architecture and feature-rich TUI provide a robust solution for a common development challenge.