How to get long running queries and CPU consuming queries from querystore views

2023-06-29T05:18:04.0966667+00:00

Using querystore views query_store.qs_view and query_store.pgms_wait_sampling_view,

how to display the long running queries and CPU consuming queries from this querystore to azure dashboard? Is there any standard method that we can suggest to our customers?

Azure Database for PostgreSQL
0 comments No comments
{count} votes

Accepted answer
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-06-29T05:38:31.6033333+00:00

    There is a Query Store in Azure Database for PostgreSQL, which you can use to analyze your workload and detect long running queries and CPU consuming queries.

    https://learn.microsoft.com/en-us/azure/postgresql/single-server/concepts-query-store

    The Query Store includes a store for wait statistics, and there is an additional capture mode query that governs wait statistics: pgms_wait_sampling.query_capture_mode can be set to none or all. The pg_qs.query_capture_mode supersedes pgms_wait_sampling.query_capture_mode. If pg_qs.query_capture_mode is none, the pgms_wait_sampling.query_capture_mode setting has no effect.

    https://docs.microsoft.com/dotnet/api/azure.identity.defaultazurecredential

    Additionally, you can use the Azure DataFactory Management client library for .NET to interact with Azure resources, including databases.

    https://github.com/Azure/azure-docs-sdk-dotnet/blob/main/api/overview/azure/preview/resourcemanager.datafactory-readme.md

    https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager.DataFactory_1.0.0-beta.2/doc/dev/mgmt_quickstart.md

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Naveen Kumar Kakarla (Quadrant Resource LLC) 125 Reputation points
    2023-06-29T05:49:49.8933333+00:00

    Thank you Salman for quick response. I appreciate it.

    When I run a query to monitor the CPU utilization using pg_stat_statements, it was showing 21% CPU utilization for 2 queries and for the same 2 queries, it was showing 7% using query store qs_view. I am just confused which one I should considered.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.