{"slug": "postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code", "title": "PostgreSQL Like A Pro: Build, query, and troubleshoot without leaving VS Code", "summary": "Microsoft's PostgreSQL extension for VS Code lets developers browse database objects, write and run SQL with IntelliSense, and query database context through GitHub Copilot without leaving the editor, according to a Microsoft walkthrough of the extension. The guide covers four workflows: saving reusable connection profiles (including Microsoft Entra ID sign-in for Azure databases), refining queries such as a quarterly customer-revenue join with Copilot's analysis of execution plans, exploring an inherited schema via Object Explorer and schema visualization, and turning latency or connection-drop symptoms into a reviewable chain of evidence. Microsoft cautions that Copilot answers and generated SQL should be verified against the database and that faster queries must still return the right results.", "body_md": "[You’re building an app in VS Code. Then you need to check a table, understand how two tables connect, or figure out why a query is slow.]\n\nThat often means opening another tool and finding your way back to the code.\n\nThe **PostgreSQL extension for VS Code** brings common database tasks into your editor. You can explore database objects, write and run SQL, and use database context with GitHub Copilot as you work.\n\nHere are four ways to make that part of your development workflow, from finding your first table to reviewing a performance recommendation. Each section includes a video from [**PostgreSQL Like a Pro: VS Code Edition**](https://aka.ms/postgresql-like-a-pro-vscode) if you’d like to follow along.\n\n## 1. Get connected and find your way around 🔌\n\nBefore writing a query, you need to know what’s in the database.\n\nInstall Microsoft’s PostgreSQL extension, then select the PostgreSQL icon in the Activity Bar to add a connection.\n\nYou can connect to on-premises or cloud databases and save connection profiles to reuse later. For a database on Azure, the Azure connection path lets you sign in with Microsoft Entra ID and select your subscription, server, and database.\n\nOnce connected, expand the server, database, and schemas to browse tables, views, functions, sequences, and extensions. Start with one table your application uses. You don’t need to understand the entire database to take the next step.\n\n💡 **Try this:** Save a connection profile, then find one table your application uses and explore its structure.\n\n## 2. Write SQL you can explain ✍️\n\nYou know what the application needs. Now you need a query that returns the right data.\n\nSuppose you need to find **which customers generated the most revenue in a quarter**. That means joining customer and payment data, adding a date filter, and grouping and sorting the results.\n\nThe query editor’s IntelliSense helps with SQL syntax, table and column names, and join expressions. Once you have a starting query, you can ask Copilot to help refine a filter or analyze its performance using query plans and execution metrics.\n\nFor a query like this, aggregating payments before joining is one possible rewrite to investigate, not a rule to apply everywhere.\n\n**Check the results as well as the execution plan.** A faster query still needs to answer the right question. Review generated SQL before running it, and compare the original and revised results.\n\n💡 **Try asking:** “Analyze this query’s performance. What does the execution plan tell us, and what should I check before changing it?”\n\n## 3. Understand a database you didn’t build 🔎\n\nWhich table contains the data you need? How does it connect to the rest of the application?\n\nThose are often the first questions when you inherit a project.\n\nStart broad in **Object Explorer**. Look for schema names, naming patterns, and tables or views that match the feature you’re working on. Then use schema visualization to trace how the relevant objects connect.\n\nWith the connected database context available in Copilot Chat, ask a focused question. For a film rental application, that might be:\n\n- Which tables contain actor and film data?\n- How are they connected?\n- Where is rental status stored?\n\nTreat the answer as a starting point, not a verified map. Check the objects in the tree, review the relationships in the visualizer, and run a small read-only query to confirm that you’re following the right data path.\n\n💡 **Try this:** Ask one discovery question, then verify the answer against the database before asking the next.\n\n## 4. Turn a performance issue into a decision you can review 📊\n\nConnection drops and rising latency tell you something is wrong. Figuring out why usually means gathering logs, comparing metrics, and building a timeline.\n\nBefore changing anything, look for a useful chain of evidence: **what changed, when it changed, which workload is involved, and why a particular action might help.**\n\nFor example, repeated customer-history lookups on a large transactions table might lead to a composite-index recommendation. The next step isn’t simply to create the index. Review the supporting metrics, expected outcome, and rollback guidance first.\n\n**Database Agent** brings these pieces together in the Azure PostgreSQL experience shown in VS Code. You can also ask Copilot for help understanding a recommendation before deciding what to do.\n\n📝 **Availability note:** The accompanying video introduces Database Agent as an upcoming experience, with actions applied manually. Check current availability and Azure requirements; automated remediation is discussed as a future capability.\n\n💡 **Before acting:** Can you explain why the change should help, how you’ll check the result, and what you’ll do if it doesn’t?\n\n## Try it ✅\n\n1. **Build with the PostgreSQL extension for VS Code:**[https://aka.ms/pg-pro-vs-code-repo](https://aka.ms/pg-pro-vs-code-repo)\n2. **Explore one table your application uses.** Inspect its structure and relationships before writing a query.\n3. **Write and review a read-only query.** Check the tables, joins, and filters, then run it and confirm the results match your requirement.\n\n**💬 Which database task takes the most detective work for you: understanding the schema, writing queries, or investigating performance? Let us know in the comments.**\n\nHappy coding! 💙", "url": "https://wpnews.pro/news/postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code", "canonical_source": "https://devblogs.microsoft.com/blog/postgresql-like-a-pro-vscode/", "published_at": "2026-10-26 15:05:12+00:00", "updated_at": "2026-11-10 21:51:59.352898+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-products"], "entities": ["Microsoft", "PostgreSQL", "VS Code", "GitHub Copilot", "Microsoft Entra ID", "Azure"], "also_reported_by": [], "takeaway": "Microsoft's PostgreSQL extension for VS Code combines connection profiles, SQL IntelliSense, schema visualization and Copilot Chat with database context, but the guide advises verifying Copilot's schema answers and comparing original versus rewritten query results before trusting a performance fix.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code", "markdown": "https://wpnews.pro/news/postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code.md", "text": "https://wpnews.pro/news/postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code.txt", "jsonld": "https://wpnews.pro/news/postgresql-like-a-pro-build-query-and-troubleshoot-without-leaving-vs-code.jsonld"}}