Skip to main content

AI editor for Aiven for PostgreSQL®

The Aiven AI editor lets you write, understand, and run SQL queries in the Aiven Console using natural language. It combines a SQL editor with an AI assistant that uses your database schema to generate and explain queries.

The AI editor supports:

  • Writing SQL in plain English or any other language
  • Visualizing your database structure with an interactive schema map
  • Exploring schemas and table relationships
  • Explaining queries and database objects
  • Running read-only queries with live results

What the AI editor includes

  • Schema visualization: View your database structure as an interactive diagram showing tables, columns and relationships. Open it from Open schema map or request it from the AI Assistant panel.
  • SQL editor: Write and edit SQL across multiple tabs, and run queries to view results in the results panel.
  • AI Assistant panel: Describe what you need in natural language. The assistant generates SQL or explains queries, tables and relationships using your database schema.

How the AI editor works

You can work by typing SQL directly or by prompting the AI Assistant.

Generate SQL with the AI Assistant

When you enter a prompt:

  • The editor provides the assistant with your schema, including tables, columns and relationships.
  • The assistant generates SQL or an explanation.
  • The SQL appears in the editor for review before you run it.

You can also ask the assistant to describe table relationships or break down complex queries.

Query execution

When you run a query, whether generated by the AI or written manually:

  • The editor executes it in a read-only transaction.
  • The results panel displays your query results.

Security and safeguards

The AI editor ensures safe, controlled access.

  • Read-only execution: All queries run in read-only mode. The editor blocks data definition statements (CREATE, ALTER, DROP) and data modification statements (INSERT, UPDATE, DELETE).
  • Single-statement validation: The AI editor allows only one SQL statement per execution.
  • Automatic safety checks: The AI editor validates all generated SQL for safety before execution.
  • Timeouts and limits:
    • Statement timeout: 30 seconds
    • Lock timeout: 10 seconds
    • Connection timeout: 10 seconds
    • Maximum result size: 5,000 rows
  • Encrypted connections: All database connections use SSL/TLS encryption.
  • Rate limiting: One request every two seconds per user per service.

Use the AI editor

To open the AI editor:

  1. In the Aiven Console, open your Aiven for PostgreSQL service.
  2. Click AI editor.
  3. Select the source database and schema.

The AI editor opens a split view with a SQL editor on the left and the AI Assistant panel on the right. Use the selectors at the top of the editor to switch the database source and schema.

Write SQL manually

  1. In the SQL editor, enter your query.
  2. Click Run.
  3. View the results in the results panel.

Generate SQL with natural language

  1. In the AI Assistant panel, describe the query or result you need.
  2. Review the generated SQL in the SQL editor.
  3. Click Run to execute the query.

Example queries to try:

  • Show monthly active users for the last 6 months
  • Find all orders with a total amount greater than 1000 dollars that are still pending
  • List customers who placed orders in the last 30 days
  • Find duplicate email addresses in the users table
  • List failed payment transactions from the last week with customer details

Ask for explanations

Use the AI Assistant panel to explain queries, break down joins and filters, and describe table relationships.

  1. Paste a query into the SQL editor.
  2. In the AI Assistant panel, request an explanation.
  3. Review the explanation of tables, joins, filters, and logic.

Explore your schema

  1. Ask a schema question in the AI Assistant panel, such as how tables relate or what a column stores.
  2. Review the response or generated SQL.
  3. Click Open schema map to browse tables and relationships visually.