diff --git a/.github/vale/styles/config/vocabularies/Aiven/accept.txt b/.github/vale/styles/config/vocabularies/Aiven/accept.txt index 3d9056ead..e0c287584 100644 --- a/.github/vale/styles/config/vocabularies/Aiven/accept.txt +++ b/.github/vale/styles/config/vocabularies/Aiven/accept.txt @@ -67,6 +67,8 @@ CPU/MS CPUs? cqlsh CRD +CTE +CTEs cron cutover Cutover diff --git a/docs/products/postgresql/howto/pg-studio.md b/docs/products/postgresql/howto/pg-studio.md index 4af3a5763..7fe6279c1 100644 --- a/docs/products/postgresql/howto/pg-studio.md +++ b/docs/products/postgresql/howto/pg-studio.md @@ -28,7 +28,7 @@ PG Studio supports: - **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. + 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 @@ -38,19 +38,32 @@ PG Studio supports: You can work by typing SQL directly or by prompting the AI Assistant. -### Generate SQL with the AI Assistant +### How AI assistance works -When you enter a prompt: +The AI Assistant lets you get help with SQL queries and database questions in natural +language. You can: -- 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. +- **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. -You can also ask the assistant to describe table relationships or break down complex -queries. +The AI Assistant uses your database schema as context for all responses, providing +accurate and relevant suggestions specific to your data structure. -### Query execution +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: @@ -82,9 +95,8 @@ To open PG Studio: 1. Click . 1. 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. +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 @@ -119,13 +131,13 @@ It runs the query where your cursor is placed. This is useful for: - Testing individual queries from a larger script -- Iterating quickly on a single query while keeping other statements in context +- 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 -1. In the AI Assistant panel, describe the query or result you need. +1. In the **AI Assistant** panel, describe the query or result you need. 1. Review the generated SQL in the SQL editor. 1. Click **Run** to execute the query. @@ -137,18 +149,36 @@ Example queries to try: - Find duplicate email addresses in the users table - List failed payment transactions from the last week with customer details -### Ask for explanations +### Ask AI about your query -Use the AI Assistant panel to explain queries, break down joins and filters, and -describe table relationships. +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. 1. Paste a query into the SQL editor. -1. In the AI Assistant panel, request an explanation. -1. Review the explanation of tables, joins, filters, and logic. +1. Optional: Highlight the part of the query to focus on. +1. Click **Ask AI** in the SQL editor. +1. In the **AI Assistant** panel, enter your request. +1. Review the explanation or updated SQL in the **AI Assistant** panel. +1. 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 `JOIN` operations combine data from multiple tables +- Clarify the purpose of `WHERE` clauses and filters +- Explain aggregate functions and `GROUP BY` operations +- Rewrite or modify a highlighted part of a query +- Optimize a selected subquery or filter condition ### Explore your schema -1. Ask a schema question in the AI Assistant panel, such as how tables relate or what a - column stores. +1. Ask a schema question in the **AI Assistant** panel, such as how tables relate or what + a column stores. 1. Review the response or generated SQL. 1. Click **Open schema map** to browse tables and relationships visually.