title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic |
---|---|---|---|---|---|---|---|---|
Query Performance Insight |
This article describes the Query Performance Insight feature in Azure Database for PostgreSQL - Flexible Server. |
varun-dhawan |
varundhawan |
maghan |
04/27/2024 |
azure-database-postgresql |
flexible-server |
conceptual |
[!INCLUDE applies-to-postgresql-flexible-server]
Query Performance Insight provides intelligent query analysis for Azure Database for PostgreSQL flexible server databases. It helps identify the top resource consuming and long-running queries in your workload. This helps you find the queries to optimize to improve overall workload performance and efficiently use the resource that you are paying for. Query Performance Insight helps you spend less time troubleshooting database performance by providing:
[!div class="checklist"]
- Identify what your long running queries, and how they change over time.
- Determine the wait types affecting those queries.
- Details on top database queries by Calls (execution count), by data-usage, by IOPS and by Temporary file usage (potential tuning candidates for performance improvements).
- The ability to drill down into details of a query, to view the Query ID and history of resource utilization.
- Deeper insight into overall databases resource consumption.
- Query Store is enabled on your database. If Query Store is not running, the Azure portal will prompt you to enable it. To enable Query Store, refer here.
Note
Query Store is currently disabled. Query Performance Insight depends on Query Store data. You need to enable it by setting the dynamic server parameter pg_qs.query_capture_mode
to either ALL or TOP.
- Query Store Wait Sampling is enabled on your database. If Query Store Wait Sampling is not running, the Azure portal will prompt you to enable it. To enable Query Store Wait Sampling, refer here.
Note
Query Store Wait Sampling is currently disabled. Query Performance Insight depends on Query Store wait sampling data. You need to enable it by setting the dynamic server parameter pgms_wait_sampling.query_capture_mode
to ALL.
- Log analytics workspace is configured for storing 3 log categories including - Azure Database for PostgreSQL flexible server Sessions logs, Azure Database for PostgreSQL flexible server Query Store and Runtime, and Azure Database for PostgreSQL flexible server Query Store Wait Statistics. To configure log analytics, refer Log analytics workspace.
Note
The Query Store data is not being transmitted to the log analytics workspace. The Azure Database for PostgreSQL flexible server logs (Sessions data / Query Store Runtime / Query Store Wait Statistics) is not being sent to the log analytics workspace, which is necessary to use Query Performance Insight. To configure the logging settings for category Azure Database for PostgreSQL flexible server sessions and send the data to a log analytics workspace.
The Query Performance Insight view in the Azure portal will surface visualizations on key information from Query Store. Query Performance Insight is easy to use:
-
Open the Azure portal and find an Azure Database for PostgreSQL flexible server instance that you want to examine.
-
From the left-side menu, open Intelligent Performance > Query Performance Insight.
-
Select a time range for investigating queries.
-
On the first tab, review the list of Long Running Queries.
-
Use sliders or zoom to change the observed interval. :::image type="content" source="./media/concepts-query-performance-insight/1-long-running-queries.png" alt-text="Screenshot of using sliders to change the observed interval.":::
-
Optionally, you can select the custom to specify a time range.
Note
For Azure Database for PostgreSQL flexible server to render the information in Query Performance Insight, Query Store needs to capture a couple hours of data. If the database has no activity or if Query Store was not active during a certain period, the charts will be empty when Query Performance Insight displays that time range. You can enable Query Store at any time if it's not running. For more information, see Best practices with Query Store.
-
To view details of a specific query, click the
QueryId Snapshot
dropdown. :::image type="content" source="./media/concepts-query-performance-insight/2-individual-query-details.png" alt-text="Screenshot of viewing details of a specific query."::: -
To get the Query Text of a specific query, connect to the
azure_sys
database on the server and queryquery_store.query_texts_view
with theQueryId
. :::image type="content" source="./media/concepts-query-performance-insight/3-view-query-text.png" alt-text="Screenshot of getting query text of a specific query."::: -
On the Consecutive tabs, you can find other query insights including:
[!div class="checklist"]
- Wait Statistics
- Top Queries by Calls
- Top Queries by Data-Usage
- Top Queries by IOPS
- Top Queries by Temporary Files
- Query Performance Insight is not available for read replicas.
- For Query Performance Insight to function, data must exist in the Query Store. Query Store is an opt-in feature, so it isn't enabled by default on a server. Query store is enabled or disabled globally for all databases on a given server and cannot be turned on or off per database.
- Enabling Query Store on the Burstable pricing tier may negatively impact performance; therefore, it's not recommended.
- Learn more about monitoring and tuning in Azure Database for PostgreSQL flexible server.