This is a beta release (v0.1-beta) and NOT production-ready software. Use at your own risk.
- This tool may suggest database changes that could impact performance
- Always test suggestions in a non-production environment first
- Back up your database before applying any changes
Database performance optimization is a critical yet complex task that requires deep expertise in SQL, query planning, and system architecture. Many organizations struggle with:
- Complex Query Analysis: Identifying bottlenecks in large SQL queries
- Schema Design Decisions: Making optimal choices for indexes and constraints
- Performance Testing: Lack of automated tools for before/after comparisons
- Risk Management: Fear of making changes that might degrade performance
- Knowledge Gap: Limited access to database optimization experts
This project aims to democratize database optimization by combining the power of Large Language Models (LLMs) with automated testing and analysis tools, making expert-level optimization accessible to all developers.
Stonebraker is an intelligent system that:
-
Analyzes Database Schemas:
- Automatically scans table structures
- Identifies missing indexes
- Suggests optimal data types
- Recommends partitioning strategies
-
Optimizes Queries:
- Rewrites complex queries for better performance
- Suggests materialized views
- Identifies common anti-patterns
- Provides explain plan analysis
-
Tests Performance:
- Runs automated benchmarks
- Compares query execution times
- Measures resource utilization
- Generates detailed reports
-
Ensures Safety:
- Provides rollback capabilities
- Tests changes in isolation
- Validates optimization impacts
- Prevents destructive changes
The AI agent leverages state-of-the-art LLMs through Groq's high-performance API or local Ollama models, combining their analytical capabilities with practical database optimization techniques.
Stonebraker is an intelligent system that combines LLM capabilities with database optimization techniques to help developers improve their PostgreSQL database performance. It analyzes schemas, suggests optimizations, and provides automated testing of changes.
- π Automated schema analysis and optimization suggestions
- π Query performance testing and benchmarking
- π οΈ LLM-powered query rewriting and improvement
- π Before/After performance comparison
- π Safe rollback capabilities
- π€ AI-driven insights for better decision making
# Clone the repository
git clone https://github.com/cloudraftio/stonebraker.git
cd stonebraker
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env with your credentials
# Start the application
streamlit run app.py
-
Python Environment
- Python 3.8 or higher
- pip package manager
- virtualenv or venv
-
PostgreSQL Setup
- PostgreSQL 14+ installed and running
- Database user with appropriate permissions
- Access to EXPLAIN ANALYZE privileges
-
LLM Provider (choose one)
- Groq API account and API key
- Ollama local setup with supported models
- Python Dependencies
pip install -r requirements.txt
- Configuration
- Copy
.env.example
to.env
- Configure database connection
- Add LLM provider credentials
- Copy
We welcome contributions! Please follow these steps:
- Check existing issues or create a new one
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
# Install dev dependencies
pip install -r requirements.txt
# Run tests
python -m pytest
- Basic schema analysis
- Query optimization suggestions
- Performance testing framework
Before contributing or deploying:
- Run
pre-commit run --all-files
to clean sensitive data - Check for credentials in git history
- Verify no API tokens in code
- Remove unnecessary files
- Issues: Use GitHub Issue Tracker
The is distributed under AGPL-3.0-only.