Skip to main content

PG Studio for Aiven for PostgreSQL® Early availability

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

important

PG Studio is an Early availability feature.

PG Studio 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 PG Studio 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 PG Studio 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:

  • PG Studio 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

PG Studio ensures safe, controlled access.

  • Read-only execution: All queries run in read-only mode. PG Studio blocks data definition statements (CREATE, ALTER, DROP) and data modification statements (INSERT, UPDATE, DELETE).
  • Single-statement validation: PG Studio allows only one SQL statement per execution.
  • Automatic safety checks: PG Studio 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 PG Studio

To open PG Studio:

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

PG Studio 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.

Run selected SQL

When working with multiple SQL statements, the editor runs one query at a time. It runs the query where your cursor is placed.

  1. In the SQL editor, place your cursor in the query to run.
  2. Click Run selected next to the active query.
  3. View the results in the results panel.

This is useful for:

  • Testing individual queries from a larger script
  • Iterating quickly on a single query while keeping other statements in context
  • Testing each subquery independently before combining a complex query
  • Verifying data in a specific table without executing setup or cleanup statements

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.