Postgresql – How to block pg_stat_reset() statement in DB

postgresqlpostgresql-9.6

Team,

Recently we have found one of our application is triggering pg_stat_reset() executing everyday which is causing performance issue . to disable this statement thru application level will take more time.

Is there any method we can disable in DB even though it trigger from application we should block it.
Please help me to resolve this.

Best Answer

Mutilating PostgreSQL would not be a good idea, so go and fix your application.

One thing that stands out here is that pg_stat_reset can only be executed by a superuser, so either you have a SECURITY DEFINER function that allows your application to call it (in which case you could simply change that function) or you are running your application as superuser, in which case you have bigger problems than performance issues.

Never, ever, run an application as superuser. It is never necessary, and it is an immense security problem.