DEV Community

Vamsi krishna
Vamsi krishna

Posted on

I Built an AI-Powered Database Query Optimizer (And Made It Open Source)

 I wanted to share a project I've been working on recently: an AI-Powered Database Query Optimizer.

The Problem: Identifying slow database queries can be tedious, and manually running EXPLAIN ANALYZE to figure out what went wrong takes time.

How it works:

It acts as a middleware monitoring PostgreSQL queries via SQLAlchemy.

If a query takes longer than a threshold (default 500ms), it flags it and automatically triggers an EXPLAIN ANALYZE.

The query structure, schema context, and execution plan are passed to the GROQ API to generate tailored indexing and optimization strategies.

Everything is fed into a live React/Vite dashboard where you can review, dismiss, or manually queue optimizations.

⚠️ Note: This is currently an MVP to prove out the core pipeline and concept—it is not yet built or intended for heavy production scaling!

Tech Stack:

Backend: FastAPI, SQLAlchemy, PostgreSQL, Pytest

Frontend: React, Vite, TypeScript

AI Layer: GROQ API

I've open-sourced the repository and also deployed a live demo if you want to check it out or trigger some simulated slow queries!

GitHub Repository : https://github.com/Dreamervamsi/AI-powered-database-query-optimiser

Live Dashboard : https://ai-powered-database-query-optimiser-cqdl.onrender.com/

I'd like to hear your thoughts on the architecture, the approach to query interception, or any features you think would make this even more useful!

Top comments (0)