A real-time PostgreSQL query performance monitoring tool built with Tauri, React, and TypeScript. PG Analyzer helps you identify slow queries, analyze execution plans, and track query performance over time.
This project is created for educational and learning purposes only. It demonstrates the integration of Tauri, React, and PostgreSQL monitoring capabilities. Please use responsibly and ensure you have proper permissions before monitoring any production databases.
- 🚀 Real-time Query Monitoring - Monitor PostgreSQL queries as they execute
- 📊 Performance Metrics - Track execution time, call frequency, and resource usage
- 🔍 Query Analysis - Get AI-powered suggestions for query optimization
- 📈 Historical Tracking - View query performance trends over time
- 🎯 Execution Plan Visualization - Interactive visualization of query execution plans
- 💾 Local Storage - Query history stored in embedded DuckDB for fast analytics
- 🎨 Modern UI - Clean, responsive interface with sortable and resizable tables
- PostgreSQL 12+ with
pg_stat_monitorextension installed - Rust 1.70+ (for building from source)
- Node.js 18+ and npm/yarn (for development)
- macOS, Windows, or Linux
The pg_stat_monitor extension is required for advanced query monitoring:
-- Install the extension
CREATE EXTENSION pg_stat_monitor;
-- Configure PostgreSQL (postgresql.conf)
shared_preload_libraries = 'pg_stat_monitor'
pg_stat_monitor.pgsm_enable_query_plan = onDownload the latest release for your platform from the Releases page.
- Clone the repository:
git clone https://github.com/Antoine-C/pg-analyzer.git
cd pg-analyzer- Install dependencies:
npm install- Build the application:
npm run tauri buildThe built application will be available in src-tauri/target/release/bundle/.
-
Launch PG Analyzer
- Open the application
- You'll be prompted to configure your PostgreSQL connection
-
Configure Database Connection
- Host: Your PostgreSQL server address
- Port: PostgreSQL port (default: 5432)
- Database: Name of the database to monitor
- Username: PostgreSQL user with appropriate permissions
- Password: User password
-
Monitor Queries
- The main dashboard shows real-time query statistics
- Click on any query to see detailed analysis
- Use the sortable columns to find problematic queries
-
Analyze Performance
- View execution plans with interactive visualization
- Get AI-powered optimization suggestions
- Track query performance history over time
- Install Rust and Cargo:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- Install Node.js dependencies:
npm install- Install Tauri CLI:
cargo install tauri-clinpm run tauri devThis will start the application in development mode with hot reloading.
pg-analyzer/
├── src/ # React frontend
│ ├── components/ # React components
│ ├── App.tsx # Main application component
│ └── ...
├── src-tauri/ # Rust backend
│ ├── src/
│ │ ├── main.rs # Application entry point
│ │ ├── postgres.rs # PostgreSQL connection logic
│ │ └── ...
│ └── Cargo.toml # Rust dependencies
├── package.json # Node.js dependencies
└── README.md
The PostgreSQL user needs the following permissions:
SELECTprivilege onpg_stat_monitorviewsCONNECTprivilege on the target database
-- Grant necessary permissions
GRANT CONNECT ON DATABASE your_database TO your_user;
GRANT SELECT ON pg_stat_monitor TO your_user;Settings are stored locally and include:
- Database connection details
- Query refresh intervals
- UI preferences
Connection Failed
- Verify PostgreSQL is running and accessible
- Check firewall settings
- Ensure pg_stat_monitor extension is installed
- Verify user permissions
No Query Data
- Ensure pg_stat_monitor is properly configured
- Check that queries are being executed on the monitored database
- Verify shared_preload_libraries includes pg_stat_monitor
Build Errors
- Update Rust:
rustup update - Clear build cache:
cargo clean - Update dependencies:
npm update
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Tauri - A framework for building native apps with web technologies
- Uses pg_stat_monitor for PostgreSQL monitoring
- Query analysis powered by OpenAI
- Data storage with DuckDB
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
Made with ❤️ for the PostgreSQL community