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.
PG Studio is an Early availability feature.
PG Studio supports:
- Writing SQL in plain English or any other language
- Autocompleting SQL queries with the
Tabkey, based on PostgreSQL commands and your schema - Visualizing your database structure with an interactive schema map
- Exploring schemas and table relationships
- Explaining queries and database objects
- Running 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.
How AI assistance works
The AI Assistant lets you get help with SQL queries and database questions in natural language. You can:
- Generate queries: Describe what data you need, and the assistant creates the SQL query for you.
- Get explanations: Ask about SQL syntax, query structure, or how specific database features work.
- Understand your schema: Request information about table structures, relationships, and data organization.
- Troubleshoot queries: Get help debugging errors, breaking down complex queries, or improving query performance.
The AI Assistant uses your database schema as context for all responses, providing accurate and relevant suggestions specific to your data structure.
When you work in the SQL editor, click Ask AI for the current statement. PG Studio opens the AI Assistant panel, attaches SQL context, and focuses the input. PG Studio sends SQL context in two parts:
- The full active SQL statement for context, including aliases, common table expressions (CTEs), and joins.
- Any highlighted SQL snippet as a separate focus area.
Executing queries
When you run a query, whether generated by the AI or written manually:
- The editor executes it.
- The results panel displays your query results.
Security and safeguards
PG Studio ensures safe, controlled access.
- 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:
- In the Aiven Console, open your Aiven for PostgreSQL service.
- Click PG Studio.
- Select the source database and schema.
PG Studio opens a split view that shows the SQL editor and the AI Assistant panel. Use the editor selectors to change the database source and schema.
Write SQL manually
-
In the SQL editor, enter your query.
UseTabto autocompletePress the
Tabkey to autocomplete SQL keywords, table names, column names, and other database objects from your schema. When the autocomplete list is open, use the arrow keys to move between suggestions and pressEnterorTabto insert the selected suggestion. PressEscto dismiss autocomplete. -
Click Run.
-
View the results in the results panel.
The autocomplete feature helps you write queries faster by suggesting:
- SQL keywords and clauses:
SELECT,FROM,WHERE,JOIN - Table names from your selected schema
- Column names from tables in your query
- Database functions and operators
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.
- In the SQL editor, place your cursor in the query to run.
- Click Run selected next to the active query.
- View the results in the results panel.
This is useful for:
- Testing individual queries from a larger script
- Iterating 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
- In the AI Assistant panel, describe the query or result you need.
- Review the generated SQL in the SQL editor.
- 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 AI about your query
Use Ask AI in the SQL editor to explain queries or create a modified version of your SQL. The AI response and any updated SQL appear in the AI Assistant panel.
- Paste a query into the SQL editor.
- Optional: Highlight the part of the query to focus on.
- Click Ask AI in the SQL editor.
- In the AI Assistant panel, enter your request.
- Review the explanation or updated SQL in the AI Assistant panel.
- Optional: Click Run query in the AI Assistant panel to move the updated SQL to the editor and execute it.
When you highlight a snippet, the AI uses it as a focused context. You can ask for an explanation of that part or request changes to it, such as rewriting a filter or optimizing a subquery.
You can Ask AI to:
- Explain what a specific SQL query does in plain language
- Break down complex queries into simpler steps
- Describe how
JOINoperations combine data from multiple tables - Clarify the purpose of
WHEREclauses and filters - Explain aggregate functions and
GROUP BYoperations - Rewrite or modify a highlighted part of a query
- Optimize a selected subquery or filter condition
Explore your schema
- Ask a schema question in the AI Assistant panel, such as how tables relate or what a column stores.
- Review the response or generated SQL.
- Click Open schema map to browse tables and relationships visually.