How to create copy of existing database in PostgreSQL

In this article, we will see how to create copy of existing database in PostgreSQL.

Postgres allows the use of any existing database on the server as a template when creating a new database.

Syntax to create copy of PostgreSQL Database:
Continue reading How to create copy of existing database in PostgreSQL

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

How to check whether a user is connected to PostgreSQL or not

In this article, we will see how to check whether a user is connected or not to PostgreSQL server. We can get this information from the system view pg_stat_activity.

Check whether user ‘james’ is connected to PostgreSQL or not

select datname from pg_stat_activity where usename='james';

Continue reading How to check whether a user is connected to PostgreSQL or not