Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Query Optimizer

A Python CLI tool that uses Google Gemini to analyze and optimize MySQL queries.

It can optionally connect to a MySQL database to retrieve table schemas and execution plans before generating recommendations.

Features

  • Explains SQL performance issues
  • Suggests query improvements
  • Recommends indexes
  • Uses MySQL schema and EXPLAIN data when available
  • Supports analysis without a database connection

Installation

git clone https://github.com/VenkatK76/query-optimizer.git
cd query-optimizer

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

pip install -r Requirements.txt

Configuration

Create a .env file in the project root:

GOOGLE_API_KEY=your_google_api_key

To enable MySQL schema and execution-plan analysis, also add:

DB_HOST=localhost
DB_PORT=3306
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=your_database_name

Usage

Analyze a query using the configured database:

python src/main.py "SELECT * FROM orders WHERE customer_id = 42;"

Analyze a query without connecting to a database:

python src/main.py --no-db "SELECT * FROM orders WHERE customer_id = 42;"

Note

The tool only provides recommendations. It does not execute optimized queries or create indexes automatically.

Review and test all generated suggestions before using them in production. :::

About

AI-powered CLI tool for analyzing and optimizing MySQL queries using Google Gemini.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages