From f9ed2bf0de9c1000d26a9554e58e1e80071b9067 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 31 Jul 2024 13:27:28 +0200 Subject: [PATCH] add performance analysis query --- doc/rbac-performance-analysis.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/rbac-performance-analysis.md b/doc/rbac-performance-analysis.md index b3a578b7..0e5fce45 100644 --- a/doc/rbac-performance-analysis.md +++ b/doc/rbac-performance-analysis.md @@ -111,7 +111,23 @@ time gw-importHostingAssets ### Fetch the Query Statistics -And afterward we can query the statistics in PostgreSQL: +And afterward we can query the statistics in PostgreSQL, e.g.: + +```SQL +WITH statements AS ( + SELECT * FROM pg_stat_statements pss +) +SELECT calls, + total_exec_time::int/(60*1000) as total_exec_time_mins, + mean_exec_time::int as mean_exec_time_millis, + query +FROM statements +WHERE calls > 100 AND shared_blks_hit > 0 +ORDER BY total_exec_time_mins DESC +LIMIT 16; +``` + +### Reset the Query Statistics ```SQL SELECT pg_stat_statements_reset();