Issue - (#33): Display all the custom configuration parameters used for pg_stat_monitor.

A new view named (pg_stat_monitor_settings) is added to see all the custom
configuration parameters and its default, min, max, and type.
pull/36/head
Ibrar Ahmed 2020-05-25 11:58:22 +00:00
parent 6b5b2e0948
commit 5536041539
6 changed files with 272 additions and 85 deletions

View File

@ -17,12 +17,12 @@ SELECT 1;
1
(1 row)
SELECT bucket, query FROM pg_stat_monitor ORDER BY query;
bucket | query
--------+--------------------------------
1 | SELECT $1
1 | SELECT pg_stat_monitor_reset()
1 | select pg_sleep($1)
SELECT query FROM pg_stat_monitor ORDER BY query;
query
--------------------------------
SELECT $1
SELECT pg_stat_monitor_reset()
select pg_sleep($1)
(3 rows)
SELECT pg_stat_monitor_reset();

134
guc.c
View File

@ -19,10 +19,104 @@
void
init_guc(void)
{
int i = 0;
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_max",
.guc_desc = "Sets the maximum number of statements tracked by pg_stat_monitor.",
.guc_default = 5000,
.guc_min = 5000,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_query_max_len",
.guc_desc = "Sets the maximum length of query.",
.guc_default = 1024,
.guc_min = 1024,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_track",
.guc_desc = "Selects which statements are tracked by pg_stat_monitor.",
.guc_default = 0,
.guc_min = 0,
.guc_max = 0,
.guc_restart = false
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_track_utility",
.guc_desc = "Selects whether utility commands are tracked.",
.guc_default = 0,
.guc_min = 0,
.guc_max = 0,
.guc_restart = false
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_normalized_query",
.guc_desc = "Selects whether save query in normalized format.",
.guc_default = 0,
.guc_min = 0,
.guc_max = 0,
.guc_restart = false
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_max_buckets",
.guc_desc = "Sets the maximum number of buckets.",
.guc_default = 10,
.guc_min = 1,
.guc_max = 10,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_bucket_time",
.guc_desc = "Sets the time in seconds per bucket.",
.guc_default = 60,
.guc_min = 1,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_object_cache",
.guc_desc = "Sets the maximum number of object cache",
.guc_default = 5,
.guc_min = 5,
.guc_max = 10,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_respose_time_lower_bound",
.guc_desc = "Sets the time in millisecond.",
.guc_default = 1,
.guc_min = 1,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.pgsm_respose_time_step",
.guc_desc = "Sets the respose time steps in millisecond.",
.guc_default = 1,
.guc_min = 1,
.guc_max = INT_MAX,
.guc_restart = true
};
conf[i++] = (GucVariable) {
.guc_name = "pg_stat_monitor.shared_buffer",
.guc_desc = "Sets the shared_buffer size.",
.guc_default = 500000,
.guc_min = 500000,
.guc_max = INT_MAX,
.guc_restart = true
};
DefineCustomIntVariable("pg_stat_monitor.max",
"Sets the maximum number of statements tracked by pg_stat_monitor.",
NULL,
&pgsm_max,
&PGSM_MAX,
5000,
5000,
INT_MAX,
@ -35,7 +129,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.query_max_len",
"Sets the maximum length of query",
NULL,
&pgsm_query_max_len,
&PGSM_QUERY_MAX_LEN,
1024,
1024,
INT_MAX,
@ -48,8 +142,8 @@ init_guc(void)
DefineCustomEnumVariable("pg_stat_monitor.track",
"Selects which statements are tracked by pg_stat_monitor.",
NULL,
&pgsm_track,
pgsm_track_TOP,
&PGSM_TRACK,
PGSM_TRACK_TOP,
track_options,
PGC_SUSET,
0,
@ -60,7 +154,7 @@ init_guc(void)
DefineCustomBoolVariable("pg_stat_monitor.track_utility",
"Selects whether utility commands are tracked by pg_stat_monitor.",
NULL,
&pgsm_track_utility,
(bool*)&PGSM_TRACK_UTILITY,
true,
PGC_SUSET,
0,
@ -71,7 +165,7 @@ init_guc(void)
DefineCustomBoolVariable("pg_stat_monitor.normalized_query",
"Selects whether save query in normalized format.",
NULL,
&pgsm_normalized_query,
(bool*)&PGSM_NORMALIZED_QUERY,
true,
PGC_SUSET,
0,
@ -79,10 +173,10 @@ init_guc(void)
NULL,
NULL);
DefineCustomIntVariable("pg_stat_monitor.pgsm_max_buckets ",
DefineCustomIntVariable("pg_stat_monitor.PGSM_MAX_buckets ",
"Sets the maximum number of buckets.",
NULL,
&pgsm_max_buckets,
&PGSM_MAX_BUCKETS,
10,
1,
10,
@ -95,7 +189,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.bucket_time",
"Sets the time in seconds per bucket.",
NULL,
&pgsm_bucket_time,
&PGSM_BUCKET_TIME,
60,
1,
INT_MAX,
@ -109,7 +203,7 @@ init_guc(void)
DefineCustomIntVariable("pg_stat_monitor.pgsm_object_cache ",
"Sets the maximum number of object cache",
NULL,
&pgsm_object_cache,
&PGSM_OBJECT_CACHE,
5,
5,
10,
@ -119,12 +213,12 @@ init_guc(void)
NULL,
NULL);
DefineCustomRealVariable("pg_stat_monitor.pgsm_respose_time_lower_bound",
DefineCustomIntVariable("pg_stat_monitor.pgsm_respose_time_lower_bound",
"Sets the time in millisecond.",
NULL,
&pgsm_respose_time_lower_bound,
.1,
.1,
&PGSM_RESPOSE_TIME_LOWER_BOUND,
1,
1,
INT_MAX,
PGC_POSTMASTER,
0,
@ -132,12 +226,12 @@ init_guc(void)
NULL,
NULL);
DefineCustomRealVariable("pg_stat_monitor.pgsm_respose_time_step",
DefineCustomIntVariable("pg_stat_monitor.pgsm_respose_time_step",
"Sets the respose time steps in millisecond.",
NULL,
&pgsm_respose_time_step,
.1,
.1,
&PGSM_RESPOSE_TIME_STEP,
1,
1,
INT_MAX,
PGC_POSTMASTER,
0,
@ -145,10 +239,10 @@ init_guc(void)
NULL,
NULL);
DefineCustomIntVariable("pg_stat_monitor.shared_buffer",
DefineCustomIntVariable("pg_stat_monitor.query_shared_buffer",
"Sets the shared_buffer size",
NULL,
&pgsm_query_buf_size,
&PGSM_QUERY_BUF_SIZE,
500000,
500000,
INT_MAX,

View File

@ -10,7 +10,7 @@ AS 'MODULE_PATHNAME'
LANGUAGE C PARALLEL SAFE;
CREATE FUNCTION pg_stat_monitor(IN showtext boolean,
OUT bucket oid,
OUT bucket int,
OUT userid oid,
OUT dbid oid,
@ -56,6 +56,29 @@ RETURNS SETOF record
AS 'MODULE_PATHNAME', 'pg_stat_wait_events'
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
CREATE FUNCTION pg_stat_monitor_settings(
OUT name text,
OUT value INTEGER,
OUT default_value INTEGER,
OUT description text,
OUT minimum INTEGER,
OUT maximum INTEGER,
OUT restart INTEGER
)
RETURNS SETOF record
AS 'MODULE_PATHNAME', 'pg_stat_monitor_settings'
LANGUAGE C STRICT VOLATILE PARALLEL SAFE;
CREATE VIEW pg_stat_monitor_settings AS SELECT
name,
value,
default_value,
description,
minimum,
maximum,
restart
FROM pg_stat_monitor_settings();
CREATE FUNCTION pg_stat_agg(
OUT queryid text,
OUT id bigint,
@ -181,6 +204,7 @@ ON agg.queryid = ss.queryid AND agg.type = 2 AND id = host;
GRANT SELECT ON pg_stat_agg_user TO PUBLIC;
GRANT SELECT ON pg_stat_agg_ip TO PUBLIC;
GRANT SELECT ON pg_stat_agg_database TO PUBLIC;
GRANT SELECT ON pg_stat_monitor_settings TO PUBLIC;
-- Don't want this to be available to non-superusers.
REVOKE ALL ON FUNCTION pg_stat_monitor_reset() FROM PUBLIC;

View File

@ -67,6 +67,7 @@ PG_FUNCTION_INFO_V1(pg_stat_monitor_1_2);
PG_FUNCTION_INFO_V1(pg_stat_monitor_1_3);
PG_FUNCTION_INFO_V1(pg_stat_monitor);
PG_FUNCTION_INFO_V1(pg_stat_wait_events);
PG_FUNCTION_INFO_V1(pg_stat_monitor_settings);
/* Extended version function prototypes */
PG_FUNCTION_INFO_V1(pg_stat_agg);
@ -231,7 +232,7 @@ pgss_shmem_startup(void)
bool found = false;
int32 i;
elog(DEBUG2, "pg_stat_monitor: %s()", __FUNCTION__);
elog(WARNING, "pg_stat_monitor: %s()", __FUNCTION__);
Assert(IsHashInitialize());
@ -260,19 +261,19 @@ pgss_shmem_startup(void)
ResetSharedState(pgss);
}
query_buf_size_bucket = pgsm_query_buf_size / pgsm_max_buckets;
for (i = 0; i < pgsm_max_buckets; i++)
query_buf_size_bucket = PGSM_QUERY_BUF_SIZE / PGSM_MAX_BUCKETS;
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
pgss_qbuf[i] = (unsigned char *) ShmemAlloc(query_buf_size_bucket);
pgss_hash = CreateHash("pg_stat_monitor: Queries hashtable",
sizeof(pgssHashKey),
sizeof(pgssEntry),
pgsm_max);
PGSM_MAX);
pgss_buckethash = CreateHash("pg_stat_monitor: Bucket hashtable",
sizeof(pgssBucketHashKey),
sizeof(pgssBucketEntry),
pgsm_max_buckets);
PGSM_MAX_BUCKETS);
pgss_waiteventshash = CreateHash("pg_stat_monitor: Wait Event hashtable",
sizeof(pgssWaitEventKey),
@ -282,12 +283,12 @@ pgss_shmem_startup(void)
pgss_object_hash = CreateHash("pg_stat_monitor: Object hashtable",
sizeof(pgssObjectHashKey),
sizeof(pgssObjectEntry),
pgsm_object_cache);
PGSM_OBJECT_CACHE);
pgss_agghash = CreateHash("pg_stat_monitor: Aggregate hashtable",
sizeof(pgssAggHashKey),
sizeof(pgssAggEntry),
pgsm_max * 3);
PGSM_MAX * 3);
Assert(!IsHashInitialize());
@ -307,8 +308,8 @@ pgss_shmem_startup(void)
}
}
pgssBucketEntries = malloc(sizeof (pgssBucketEntry) * pgsm_max_buckets);
for (i = 0; i < pgsm_max_buckets; i++)
pgssBucketEntries = malloc(sizeof (pgssBucketEntry) * PGSM_MAX_BUCKETS);
for (i = 0; i < PGSM_MAX_BUCKETS; i++)
{
pgssBucketHashKey key;
pgssBucketEntry *entry = NULL;
@ -463,7 +464,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
* counting of optimizable statements that are directly contained in
* utility statements.
*/
if (pgss_enabled() && queryDesc->plannedstmt->queryId != UINT64CONST(0))
if (PGSS_ENABLED() && queryDesc->plannedstmt->queryId != UINT64CONST(0))
{
/*
* Set up to track total elapsed time in ExecutorRun. Make sure the
@ -538,7 +539,7 @@ pgss_ExecutorEnd(QueryDesc *queryDesc)
float utime;
float stime;
if (queryId != UINT64CONST(0) && queryDesc->totaltime && pgss_enabled())
if (queryId != UINT64CONST(0) && queryDesc->totaltime && PGSS_ENABLED())
{
/*
* Make sure stats accumulation is done. (Note: it's okay if several
@ -597,7 +598,7 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
*
* Likewise, we don't track execution of DEALLOCATE.
*/
if (pgsm_track_utility && pgss_enabled() &&
if (PGSM_TRACK_UTILITY && PGSS_ENABLED() &&
!IsA(parsetree, ExecuteStmt) &&
!IsA(parsetree, PrepareStmt) &&
!IsA(parsetree, DeallocateStmt))
@ -889,7 +890,7 @@ pgss_store(const char *query, uint64 queryId,
goto exit;
}
if (pgsm_normalized_query)
if (PGSM_NORMALIZED_QUERY)
store_query(queryId, norm_query ? norm_query : query, query_len);
else
store_query(queryId, query, query_len);
@ -949,13 +950,13 @@ pgss_store(const char *query, uint64 queryId,
for (i = 0; i < MAX_RESPONSE_BUCKET - 1; i++)
{
if (total_time < pgsm_respose_time_lower_bound + (pgsm_respose_time_step * i))
if (total_time < PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * i))
{
pgssBucketEntries[entry->key.bucket_id]->counters.resp_calls[i]++;
break;
}
}
if (total_time > pgsm_respose_time_lower_bound + (pgsm_respose_time_step * MAX_RESPONSE_BUCKET))
if (total_time > PGSM_RESPOSE_TIME_LOWER_BOUND + (PGSM_RESPOSE_TIME_STEP * MAX_RESPONSE_BUCKET))
pgssBucketEntries[entry->key.bucket_id]->counters.resp_calls[MAX_RESPONSE_BUCKET - 1]++;
e->counters.calls.rows += rows;
@ -1005,14 +1006,6 @@ pg_stat_monitor_reset(PG_FUNCTION_ARGS)
#define PG_STAT_STATEMENTS_COLS 31 /* maximum of above */
Datum
pg_stat_monitor(PG_FUNCTION_ARGS)
{
/* If it's really API 1.1, we'll figure that out below */
pg_stat_monitor_internal(fcinfo, true);
return (Datum) 0;
}
Datum
pg_stat_wait_events(PG_FUNCTION_ARGS)
{
@ -1025,7 +1018,7 @@ pg_stat_wait_events(PG_FUNCTION_ARGS)
pgssWaitEventEntry *entry;
char *query_txt;
char queryid_txt[64];
query_txt = (char*) malloc(pgsm_query_max_len);
query_txt = (char*) malloc(PGSM_QUERY_MAX_LEN);
/* hash table must exist already */
if (!pgss || !pgss_hash || !pgss_object_hash)
@ -1107,6 +1100,15 @@ pg_stat_wait_events(PG_FUNCTION_ARGS)
return (Datum) 0;
}
Datum
pg_stat_monitor(PG_FUNCTION_ARGS)
{
/* If it's really API 1.1, we'll figure that out below */
pg_stat_monitor_internal(fcinfo, true);
return (Datum) 0;
}
/* Common code for all versions of pg_stat_statements() */
static void
pg_stat_monitor_internal(FunctionCallInfo fcinfo,
@ -1123,7 +1125,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
pgssEntry *entry;
char *query_txt;
char queryid_txt[64];
query_txt = (char*) malloc(pgsm_query_max_len);
query_txt = (char*) malloc(PGSM_QUERY_MAX_LEN);
/* Superusers or members of pg_read_all_stats members are allowed */
is_allowed_role = is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS);
@ -1282,7 +1284,7 @@ pgss_memsize(void)
Size size;
size = MAXALIGN(sizeof(pgssSharedState));
size = add_size(size, hash_estimate_size(pgsm_max, sizeof(pgssEntry)));
size = add_size(size, hash_estimate_size(PGSM_MAX, sizeof(pgssEntry)));
return size;
}
@ -1311,13 +1313,13 @@ entry_alloc(pgssSharedState *pgss, pgssHashKey *key, Size query_offset, int quer
pgssEntry *entry = NULL;
bool found = false;
if (pgss->bucket_entry[pgss->current_wbucket] >= (pgsm_max / pgsm_max_buckets))
if (pgss->bucket_entry[pgss->current_wbucket] >= (PGSM_MAX / PGSM_MAX_BUCKETS))
{
pgss->bucket_overflow[pgss->current_wbucket]++;
return NULL;
}
if (hash_get_num_entries(pgss_hash) >= pgsm_max)
if (hash_get_num_entries(pgss_hash) >= PGSM_MAX)
return NULL;
/* Find or create an entry with desired hash code */
@ -1349,10 +1351,10 @@ get_next_wbucket(pgssSharedState *pgss)
gettimeofday(&tv,NULL);
current_usec = tv.tv_sec;
if ((current_usec - pgss->prev_bucket_usec) > pgsm_bucket_time)
if ((current_usec - pgss->prev_bucket_usec) > PGSM_BUCKET_TIME)
{
bucket_id = pgss->current_wbucket + 1;
if (bucket_id == pgsm_max_buckets)
if (bucket_id == PGSM_MAX_BUCKETS)
bucket_id = 0;
LWLockAcquire(pgss->lock, LW_EXCLUSIVE);
@ -2578,8 +2580,8 @@ store_query(uint64 queryid, const char *query, uint64 query_len)
int next;
int offset = 0;
if (query_len > pgsm_query_max_len)
query_len = pgsm_query_max_len;
if (query_len > PGSM_QUERY_MAX_LEN)
query_len = PGSM_QUERY_MAX_LEN;
/* Already have query in the shared buffer, there
* is no need to add that again.
@ -2719,3 +2721,57 @@ get_query_id(pgssJumbleState *jstate, Query *query)
return queryid;
}
Datum
pg_stat_monitor_settings(PG_FUNCTION_ARGS)
{
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
TupleDesc tupdesc;
Tuplestorestate *tupstore;
MemoryContext per_query_ctx;
MemoryContext oldcontext;
int i;
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("pg_stat_monitor: set-valued function called in context that cannot accept a set")));
/* Switch into long-lived context to construct returned data structures */
per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
oldcontext = MemoryContextSwitchTo(per_query_ctx);
/* Build a tuple descriptor for our result type */
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "pg_stat_monitor: return type must be a row type");
if (tupdesc->natts != 7)
elog(ERROR, "pg_stat_monitor: incorrect number of output arguments, required %d", tupdesc->natts);
tupstore = tuplestore_begin_heap(true, false, work_mem);
rsinfo->returnMode = SFRM_Materialize;
rsinfo->setResult = tupstore;
rsinfo->setDesc = tupdesc;
MemoryContextSwitchTo(oldcontext);
for(i = 0; i < 11; i++)
{
Datum values[7];
bool nulls[7];
int j = 0;
memset(values, 0, sizeof(values));
memset(nulls, 0, sizeof(nulls));
values[j++] = CStringGetTextDatum(conf[i].guc_name);
values[j++] = Int64GetDatumFast(conf[i].guc_variable);
values[j++] = Int64GetDatumFast(conf[i].guc_default);
values[j++] = CStringGetTextDatum(conf[i].guc_desc);
values[j++] = Int64GetDatumFast(conf[i].guc_min);
values[j++] = Int64GetDatumFast(conf[i].guc_max);
values[j++] = Int64GetDatumFast(conf[i].guc_restart);
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
}
/* clean up and return the tuplestore */
tuplestore_donestoring(tupstore);
return (Datum)0;
}

View File

@ -61,6 +61,18 @@
#define MAX_REL_LEN 255
#define MAX_BUCKETS 10
#define MAX_OBJECT_CACHE 100
#define TEXT_LEN 255
typedef struct GucVariables
{
int guc_variable;
char guc_name[TEXT_LEN];
char guc_desc[TEXT_LEN];
int guc_default;
int guc_min;
int guc_max;
bool guc_restart;
} GucVariable;
/*
* Type of aggregate keys
@ -300,37 +312,38 @@ typedef struct pgssJumbleState
typedef enum
{
pgsm_track_NONE, /* track no statements */
pgsm_track_TOP, /* only top level statements */
pgsm_track_ALL /* all statements, including nested ones */
} PGSSTrackLevel;
PGSM_TRACK_NONE, /* track no statements */
PGSM_TRACK_TOP, /* only top level statements */
PGSM_TRACK_ALL /* all statements, including nested ones */
} PGSSTRACKlEVEL;
static const struct config_enum_entry track_options[] =
{
{"none", pgsm_track_NONE, false},
{"top", pgsm_track_TOP, false},
{"all", pgsm_track_ALL, false},
{"none", PGSM_TRACK_NONE, false},
{"top", PGSM_TRACK_TOP, false},
{"all", PGSM_TRACK_ALL, false},
{NULL, 0, false}
};
#define pgss_enabled() \
(pgsm_track == pgsm_track_ALL || \
(pgsm_track == pgsm_track_TOP && nested_level == 0))
#endif
#define PGSS_ENABLED() \
(PGSM_TRACK == PGSM_TRACK_ALL || \
(PGSM_TRACK == PGSM_TRACK_TOP && nested_level == 0))
/* guc.c */
void init_guc(void);
/*---- GUC variables ----*/
int pgsm_max; /* max # statements to track */
int pgsm_track; /* tracking level */
bool pgsm_track_utility; /* whether to track utility commands */
int pgsm_bucket_time; /* bucket maximum time */
int pgsm_max_buckets; /* total number of buckets */
int pgsm_object_cache; /* total number of objects cache */
bool pgsm_normalized_query; /* save normaized query or not */
int pgsm_query_max_len; /* max query length */
int pgsm_query_buf_size; /* maximum size of the query */
double pgsm_respose_time_lower_bound;
double pgsm_respose_time_step;
#define PGSM_MAX conf[0].guc_variable
#define PGSM_QUERY_MAX_LEN conf[1].guc_variable
#define PGSM_TRACK conf[2].guc_variable
#define PGSM_TRACK_UTILITY conf[3].guc_variable
#define PGSM_NORMALIZED_QUERY conf[4].guc_variable
#define PGSM_MAX_BUCKETS conf[5].guc_variable
#define PGSM_BUCKET_TIME conf[6].guc_variable
#define PGSM_QUERY_BUF_SIZE conf[7].guc_variable
#define PGSM_OBJECT_CACHE conf[8].guc_variable
#define PGSM_RESPOSE_TIME_LOWER_BOUND conf[9].guc_variable
#define PGSM_RESPOSE_TIME_STEP conf[10].guc_variable
GucVariable conf[11];
#endif

View File

@ -2,6 +2,6 @@ CREATE EXTENSION pg_stat_monitor;
SELECT pg_stat_monitor_reset();
select pg_sleep(.5);
SELECT 1;
SELECT bucket, query FROM pg_stat_monitor ORDER BY query;
SELECT query FROM pg_stat_monitor ORDER BY query;
SELECT pg_stat_monitor_reset();
DROP EXTENSION pg_stat_monitor;