|
1 |
| -# This is postgres performant agent |
| 1 | +# Stonebraker: The PostgreSQL Performance Optimization AI Agent 🚀 |
2 | 2 |
|
3 |
| -### Setup |
| 3 | +[](https://www.gnu.org/licenses/agpl-3.0) |
| 4 | +[](https://www.python.org/downloads/) |
| 5 | +[](https://www.postgresql.org/) |
| 6 | +[](https://github.com/yourusername/stonebraker/releases) |
4 | 7 |
|
5 |
| -#### .env Setup |
6 |
| -```.env |
7 |
| -GROQ_API_KEY="" |
8 |
| -GROQ_MODEL="llama-3.3-70b-specdec" |
9 |
| -ANALYZING_MODEL="deepseek-r1-distill-llama-70b-specdec" |
10 |
| -OLLAMA_MODEL="llama3.2" |
| 8 | +## ⚠️ Disclaimer |
| 9 | + |
| 10 | +**This is a beta release (v0.1-beta) and NOT production-ready software. Use at your own risk.** |
| 11 | +- This tool may suggest database changes that could impact performance |
| 12 | +- Always test suggestions in a non-production environment first |
| 13 | +- Back up your database before applying any changes |
| 14 | + |
| 15 | +## Motivation 💭 |
| 16 | + |
| 17 | +Database performance optimization is a critical yet complex task that requires deep expertise in SQL, query planning, and system architecture. Many organizations struggle with: |
| 18 | + |
| 19 | +- **Complex Query Analysis**: Identifying bottlenecks in large SQL queries |
| 20 | +- **Schema Design Decisions**: Making optimal choices for indexes and constraints |
| 21 | +- **Performance Testing**: Lack of automated tools for before/after comparisons |
| 22 | +- **Risk Management**: Fear of making changes that might degrade performance |
| 23 | +- **Knowledge Gap**: Limited access to database optimization experts |
| 24 | + |
| 25 | +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. |
| 26 | + |
| 27 | +## Project Description 📝 |
| 28 | + |
| 29 | +Stonebraker is an intelligent system that: |
| 30 | + |
| 31 | +1. **Analyzes Database Schemas**: |
| 32 | + - Automatically scans table structures |
| 33 | + - Identifies missing indexes |
| 34 | + - Suggests optimal data types |
| 35 | + - Recommends partitioning strategies |
| 36 | + |
| 37 | +2. **Optimizes Queries**: |
| 38 | + - Rewrites complex queries for better performance |
| 39 | + - Suggests materialized views |
| 40 | + - Identifies common anti-patterns |
| 41 | + - Provides explain plan analysis |
| 42 | + |
| 43 | +3. **Tests Performance**: |
| 44 | + - Runs automated benchmarks |
| 45 | + - Compares query execution times |
| 46 | + - Measures resource utilization |
| 47 | + - Generates detailed reports |
| 48 | + |
| 49 | +4. **Ensures Safety**: |
| 50 | + - Provides rollback capabilities |
| 51 | + - Tests changes in isolation |
| 52 | + - Validates optimization impacts |
| 53 | + - Prevents destructive changes |
| 54 | + |
| 55 | +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. |
| 56 | + |
| 57 | +## 🎯 Introduction |
| 58 | + |
| 59 | +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. |
| 60 | + |
| 61 | +### Key Features |
| 62 | + |
| 63 | +- 🔍 Automated schema analysis and optimization suggestions |
| 64 | +- 📊 Query performance testing and benchmarking |
| 65 | +- 🛠️ LLM-powered query rewriting and improvement |
| 66 | +- 📈 Before/After performance comparison |
| 67 | +- 🔄 Safe rollback capabilities |
| 68 | +- 🤖 AI-driven insights for better decision making |
| 69 | + |
| 70 | +## 🚀 Quick Start |
| 71 | + |
| 72 | +```bash |
| 73 | +# Clone the repository |
| 74 | +git clone https://github.com/cloudraftio/stonebraker.git |
| 75 | +cd stonebraker |
| 76 | + |
| 77 | +# Create and activate virtual environment |
| 78 | +python -m venv venv |
| 79 | +source venv/bin/activate |
| 80 | + |
| 81 | +# Install dependencies |
| 82 | +pip install -r requirements.txt |
| 83 | + |
| 84 | +# Set up environment variables |
| 85 | +cp .env.example .env |
| 86 | +# Edit .env with your credentials |
| 87 | + |
| 88 | +# Start the application |
| 89 | +streamlit run app.py |
11 | 90 | ```
|
12 | 91 |
|
13 |
| -#### Prerequisites |
14 |
| -- Python |
15 |
| -- Groq/Ollama API Keys |
| 92 | +## 📋 Prerequisites |
| 93 | + |
| 94 | +1. **Python Environment** |
| 95 | + - Python 3.8 or higher |
| 96 | + - pip package manager |
| 97 | + - virtualenv or venv |
| 98 | + |
| 99 | +2. **PostgreSQL Setup** |
| 100 | + - PostgreSQL 14+ installed and running |
| 101 | + - Database user with appropriate permissions |
| 102 | + - Access to EXPLAIN ANALYZE privileges |
| 103 | + |
| 104 | +3. **LLM Provider (choose one)** |
| 105 | + - Groq API account and API key |
| 106 | + - Ollama local setup with supported models |
| 107 | + |
| 108 | +## 🔧 Installation Details |
| 109 | + |
| 110 | +1. **Python Dependencies** |
| 111 | +```bash |
| 112 | +pip install -r requirements.txt |
| 113 | +``` |
| 114 | + |
| 115 | +2. **Configuration** |
| 116 | + - Copy `.env.example` to `.env` |
| 117 | + - Configure database connection |
| 118 | + - Add LLM provider credentials |
| 119 | + |
| 120 | +## 📖 Example Usage |
| 121 | + |
| 122 | +*StonebrakerAI Dashboard* |
| 123 | + |
| 124 | +## 🤝 Contributing |
| 125 | + |
| 126 | +We welcome contributions! Please follow these steps: |
| 127 | + |
| 128 | +1. Check existing issues or create a new one |
| 129 | +2. Fork the repository |
| 130 | +3. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 131 | +4. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 132 | +5. Push to the branch (`git push origin feature/amazing-feature`) |
| 133 | +6. Open a Pull Request |
| 134 | + |
| 135 | +### Development Setup |
| 136 | +```bash |
| 137 | +# Install dev dependencies |
| 138 | +pip install -r requirements.txt |
| 139 | + |
| 140 | +# Run tests |
| 141 | +python -m pytest |
| 142 | +``` |
| 143 | + |
| 144 | +## 🗺️ Roadmap |
| 145 | + |
| 146 | +### v0.1-beta (Current) |
| 147 | +- [x] Basic schema analysis |
| 148 | +- [x] Query optimization suggestions |
| 149 | +- [x] Performance testing framework |
| 150 | + |
| 151 | +## 🧹 Security & Maintenance |
| 152 | + |
| 153 | +Before contributing or deploying: |
| 154 | +1. Run `pre-commit run --all-files` to clean sensitive data |
| 155 | +2. Check for credentials in git history |
| 156 | +3. Verify no API tokens in code |
| 157 | +4. Remove unnecessary files |
| 158 | + |
| 159 | +## 📞 Contact & Support |
| 160 | + |
| 161 | +- **Issues**: Use [GitHub Issue Tracker](https://github.com/yourusername/stonebraker/issues) |
| 162 | +- **Discussion**: Join our [Slack Channel](https://github.com/cloudraftio/stonebraker) |
| 163 | + |
| 164 | +## 📄 License |
16 | 165 |
|
17 |
| -1. `pip install -r requirements.txt` |
18 |
| -2. Set up your API keys/url endpoints. |
19 |
| -3. test out the code : `python testing.py` |
| 166 | +The is distributed under AGPL-3.0-only. |
0 commit comments