To reset PostgreSQL’s cumulative statistics for the current database, run:
SELECT pg_stat_reset();
That, per the postgres docs, zeroes the per-table, per-index and per-function counters for the database you are connected to — seq_scan, idx_scan, n_live_tup, vacuum_count, and the last_vacuum / last_analyze timestamps. It does not touch the statistics the query planner uses, and it does not affect any other database. To reset one table instead, use SELECT pg_stat_reset_single_table_counters('schema.table'::regclass);
All output below was produced on PostgreSQL 17.10 on 2026-08-09 by a script that builds its own temporary cluster, runs the reset, GRANT EXECUTE and planner-statistics checks from this page against it, deletes the cluster on exit, and leaves any database you already have untouched.
Table of Contents
What pg_stat_reset() does not clear, and who can run it
pg_stat_reset() does not clear pg_stat_activity. pg_stat_activity is a live view of what each backend is doing right now, assembled on demand — it is not accumulated data and there is nothing in it to reset. Measured before and after a reset on 17.10, the row count was 5 both times. If a connection is showing up in pg_stat_activity and you want it gone, you terminate the backend; resetting statistics will never do it.
There is no pg_stat_reset role. A query for it returns zero rows:
select count(*) from pg_roles where rolname='pg_stat_reset';
0
What actually governs access is ordinary function permissions. By default a plain role gets ERROR: permission denied for function pg_stat_reset, and the fix is a grant, not a superuser account:
GRANT EXECUTE ON FUNCTION pg_stat_reset() TO appuser;
After that grant, a role with rolsuper = f ran the reset successfully. A monitoring task like this does not need superuser.
Resetting does not remove data that affects query planning. Cumulative statistics and planner statistics are two separate systems that unfortunately share a name. Planner statistics are gathered by ANALYZE, stored in pg_statistic, and read through pg_stats; pg_stat_reset() leaves them completely alone. Verified across a reset on 17.10:
pg_stats rows for table s : 2 -> 2 (unchanged)
pg_class.reltuples : 20000 -> 20000 (unchanged)
seq_scan : 1 -> 0 (reset)
last_vacuum : set -> NULL (reset)
Your query plans will not degrade because you reset statistics. The real cost is different, and covered below.
The term “stats collector” is stale: that process was removed in PostgreSQL 15, when cumulative statistics moved into shared memory. On 15 and later there is no stats collector process to talk about.
What resetting actually costs you
The genuine downside is that autovacuum makes its decisions from exactly these counters. n_dead_tup and n_mod_since_analyze go to zero along with everything else — in the run above n_live_tup dropped from 20000 to 0 — so autovacuum briefly believes every table is untouched and will not queue work it would otherwise have queued. The counters rebuild as traffic comes in, but you have thrown away the backlog signal in the meantime.
You also lose your monitoring baseline. Anything computing deltas from pg_stat_user_tables will see counters run backwards and may report a spike or a gap. Reset deliberately, not reflexively.
The other two reset functions
pg_stat_reset_shared(text) clears cluster-wide statistics that pg_stat_reset() does not cover. On 17.10 the valid targets are enumerated by the server’s own error message when you pass a bad one:
ERROR: unrecognized reset target: "bogus"
HINT: Target must be "archiver", "bgwriter", "checkpointer", "io", "recovery_prefetch", "slru", or "wal".
All seven were accepted individually, and the no-argument form SELECT pg_stat_reset_shared(); was also accepted, resetting all of them.
pg_stat_reset_single_table_counters(oid) is the surgical option, and it really is limited to one table. With two tables both showing scans, resetting one left the other untouched:
before: s seq_scan > 0, other seq_scan > 0
after pg_stat_reset_single_table_counters('s'::regclass):
s seq_scan = 0, other seq_scan > 0
This is almost always the better choice when you are measuring the effect of one change on one table.
Worth knowing
Statistics for extensions are separate. pg_stat_statements has its own pg_stat_statements_reset(); pg_stat_reset() will not clear it. And you rarely need to reset at all after a crash: PostgreSQL discards all counters automatically after an unclean shutdown, an immediate stop, or a restore from base backup, while a clean shutdown preserves them in the pg_stat subdirectory.