I will optimize slow sql queries and cut llm api token costs efficiently
Python, SQL, AI Automation Engineer
About this Gig
Stop letting unoptimized SQL joins and expensive flagship LLM API calls drain your engineering budget every month.
Using AST-based SQL query analysis and intelligent Python model routing, I identify database latency bottlenecks and cut recurring LLM token costs by 40% to 70% without sacrificing output accuracy.
What I Deliver:
SQL Execution & AST Audit: Deep inspection of slow PostgreSQL, SQLite, or MySQL queries, missing indexes, and full-table scans with high-speed rewritten queries.
Smart LLM Model Routing: Python middleware that automatically routes routine tasks to fast, low-cost models while reserving frontier models for complex reasoning.
Prompt & Token Compression: Elimination of redundant context tokens and structured JSON output enforcement.
Before/After Benchmark Report: Clear metrics showing query latency improvements and projected monthly token savings.
Production-Ready Code: Clean Python/FastAPI code with unit tests (pytest) and Docker support.
Message me with your slow SQL queries (EXPLAIN ANALYZE) or current LLM workflow before ordering to confirm the exact scope.
Platform:
BigQuery
•
MariaDB
•
MS SQL
•
MySQL
•
PostgreSQL
•
SQLite
My Portfolio
FAQ
- Do you need direct access to our live production database?
No. Anonymized table schemas (DDL), sample queries, and EXPLAIN ANALYZE outputs are completely sufficient for a full audit and rewrite.
- Will LLM model routing reduce the response quality of our AI app?
No. Simple classification, extraction, and formatting tasks are routed to lightweight models, while complex reasoning stays on top-tier models.
- Which databases and AI providers do you support?
I support PostgreSQL, SQLite, MySQL, and BigQuery on the SQL side, along with OpenAI, Anthropic Claude, Gemini, and LangChain/FastAPI.

