1

Pg_stats_actvity is used in pgadmin 4 but it give only current queries.

And also checked on azure portal for logs in server logs there can't see the logs for queries.

If anyone know help on this it is azure postgresql server.

Need Queries for one perticular database.

I tried below query in pgadmin 4

Select * from pg_stats_activity

It is azure postgresql single server i checked logs and diagnostics. Also tried explain analyse.

Help me to get list of queries in postgresql database for perticular time interval

1 Answers1

0

You have several options in Postgres to capture queries.

You've already found that pg_stats_activity shows active, running queries.

The pg_stat_statements extension will show aggregated information for query fingerprints.

The log_statement configuration will log queries that were sent to the database into your postgres.log. Use the log_line_prefix configuration to capture more details into the logs.

The pgaudit extension will capture queries that were executed on the database, with nicely formatted output for easy parsing or to send to log aggregation tools.

Here's an Azure doc that describes how to set these in the UI and how to view the resulting logs: https://learn.microsoft.com/en-us/azure/postgresql/single-server/concepts-server-logs.

In your case, setting log_statement to 'all' should be a good start.

Valerie Parham-Thompson
  • 1,516
  • 1
  • 11
  • 21