Postgresql – Prevent execution of heavy-loading and / or runaway queries in postgres

postgresql

Is there a way to stop/kill queries being executed on a postgres database based on criteria such as:

  • maximum execution time
  • load (CPU and/or memory) imposed on the server?

Best Answer

You can use statement_timeout to limit execution time: https://www.postgresql.org/docs/current/runtime-config-client.html