diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index 74a58a916c..2281ba120f 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -5097,7 +5097,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
Resets statistics for a single table or index in the current database
- to zero.
+ or shared across all databases in the cluster to zero.
This function is restricted to superusers by default, but other users
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 4a280897b1..3450a10129 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -38,6 +38,7 @@
#include "access/transam.h"
#include "access/twophase_rmgr.h"
#include "access/xact.h"
+#include "catalog/catalog.h"
#include "catalog/pg_database.h"
#include "catalog/pg_proc.h"
#include "common/ip.h"
@@ -5140,7 +5141,8 @@ pgstat_recv_resetsharedcounter(PgStat_MsgResetsharedcounter *msg, int len)
/* ----------
* pgstat_recv_resetsinglecounter() -
*
- * Reset a statistics for a single object
+ * Reset a statistics for a single object, which may be of current
+ * database or shared across all databases in the cluster.
* ----------
*/
static void
@@ -5148,7 +5150,10 @@ pgstat_recv_resetsinglecounter(PgStat_MsgResetsinglecounter *msg, int len)
{
PgStat_StatDBEntry *dbentry;
- dbentry = pgstat_get_db_entry(msg->m_databaseid, false);
+ if (IsSharedRelation(msg->m_objectid))
+ dbentry = pgstat_get_db_entry(InvalidOid, false);
+ else
+ dbentry = pgstat_get_db_entry(msg->m_databaseid, false);
if (!dbentry)
return;
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 4f170eaf48..1a750a49ca 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -5754,7 +5754,7 @@
proname => 'pg_stat_reset_shared', provolatile => 'v', prorettype => 'void',
proargtypes => 'text', prosrc => 'pg_stat_reset_shared' },
{ oid => '3776',
- descr => 'statistics: reset collected statistics for a single table or index in the current database',
+ descr => 'statistics: reset collected statistics for a single table or index in the current database or shared across all databases in the cluster',
proname => 'pg_stat_reset_single_table_counters', provolatile => 'v',
prorettype => 'void', proargtypes => 'oid',
prosrc => 'pg_stat_reset_single_table_counters' },