How to get list of sessions on PostgreSQL database

In this article, we will see how to get list of sessions on PostgreSQL database. We will see all sessions in PostgreSQL and sessions specific to the database. We can get session by running queries against pg_stat_activity.

Syntax to get list of sessions on PostgreSQL database: Continue reading How to get list of sessions on PostgreSQL database

How to kill PostgreSQL process/session/connection

In this article, we will see how to kill PostgreSQL process ID step by step. we can kill process id by using the function pg_terminate_backend(). To execute this, we must must have superuser privileges.

Query to kill Postgres Process: Continue reading How to kill PostgreSQL process/session/connection

How to find long running queries in PostgreSQL

As administrator, From time to time we need to investigate if there is any query running indefinitely on PostgreSQL. These long running queries may impact database performance and probably they are stuck on some background process.

Long running queries in PostgreSQL

1. Following queries will return currently running top 10 queries and longest running queries in the front.
Continue reading How to find long running queries in PostgreSQL