pg_ai_query — AI-powered SQL generation & query analysis for PostgreSQL

Posted on 2025-11-23 by benodiwal
Related Open Source

I am excited to announce the release of pg_ai_query — a PostgreSQL extension that brings AI-powered query development directly into Postgres.

pg_ai_query allows you to:

  • Generate SQL from natural language, e.g.
    SELECT generate_query('list customers who have not placed an order in the last 90 days');
  • Analyze query performance using AI-interpreted EXPLAIN ANALYZE
  • Receive index and rewrite recommendations
  • Leverage schema-aware query intelligence with secure introspection

Designed to help developers write and tune SQL faster without switching tools and to accelerate iteration across complex workloads.
Documentation and installation instructions: https://benodiwal.github.io/pg_ai_query

Source code: https://github.com/benodiwal/pg_ai_query

pg_ai_query supports PostgreSQL 14+.
Feedback and contributions are very welcome. The project is actively maintained and evolving with community guidance.

Best regards, Sachin Beniwal
benodiwal