Delen via


Query's voor de tabel PGSQLPgStatActivitySessions

Zie de zelfstudie over Log Analytics voor meer informatie over het gebruik van deze query's in Azure Portal. Zie Query voor de REST API.

Langste sessies

Zoek naar langste sessies, ongeacht de status.

PGSQLPgStatActivitySessions
| where UserId != 10 //exclude azure managed user
| where BackendType =='client backend'
| where isnotempty(DatabaseId) and DatabaseName !in('azure_sys','azure_maintenance')
| extend ConnectionDurationSec = datetime_diff('second',CollectionTime,BackendStartTime)
| summarize maxConnectionDurationSeconds=max(ConnectionDurationSec),arg_max(LastSampledTime=TimeGenerated,lastState=State) by ProcessId,BackendStartTime,DatabaseName,UserId,ApplicationName,ClientIpAddress
| order by maxConnectionDurationSeconds desc
| take 100

Langste transacties

Zoeksessies en TransactionIds met langste uitvoeringstijd.

PGSQLPgStatActivitySessions
| where UserId != 10 and State !='idle' //exclude azure managed user and idle sessions
| where BackendType =='client backend'
| where isnotempty(DatabaseId) and DatabaseName !in('azure_sys','azure_maintenance')
| extend TransactionDurationMs = datetime_diff('millisecond',CollectionTime,TransactionStartTime)
| summarize MaxTransactionDurationMs=max(TransactionDurationMs),arg_max(LastSampledTime=TimeGenerated,lastState=State) by ProcessId,BackendStartTime,TransactionId,DatabaseName,UserId,ApplicationName,ClientIpAddress
| order by MaxTransactionDurationMs desc
| take 100

Sessies met lange query's

Zoek naar sessies met verhoogde uitvoeringstijd voor query's.

PGSQLPgStatActivitySessions
| where UserId != 10 and State !='idle' //exclude azure managed user and idle sessions
| where BackendType =='client backend'
| where isnotempty(DatabaseId) and DatabaseName !in('azure_sys','azure_maintenance')
| extend QueryExecDurationMs = datetime_diff('millisecond',CollectionTime,QueryStartTime)
| summarize MaxQueryExecDurationMs=max(QueryExecDurationMs),arg_max(LastSampledTime=TimeGenerated,lastState=State) by ProcessId,BackendStartTime,DatabaseName,UserId,ApplicationName,ClientIpAddress
| order by MaxQueryExecDurationMs desc
| take 100