Question: How can I get information about a PostgreSQL cluster?


Getting information about a PostgreSQL cluster involves understanding both the configuration and the current operational status of the cluster. Here are a few ways you can gather this information:

1. Using pg_controldata

The pg_controldata utility provides information about the PostgreSQL server's control file. This command needs to be run on a database cluster directory (where the data files reside).

pg_controldata /path/to/your/data/directory

This will output various pieces of information like checkpoint locations, database system identifier, database version, and more.

2. Checking Cluster Status with pg_lsclusters (Debian and Ubuntu)

On Debian-based systems, pg_lsclusters from the postgresql-common package gives a good overview of all PostgreSQL clusters running on the system.


This will list each cluster along with its version, port, status, owner, and data directory.

3. Querying the Catalog Views

PostgreSQL has several catalog views that can provide in-depth details about the databases, tables, indexes, users, and other internal entities. For example, to see information about the databases in your cluster:

SELECT datname, encoding, datcollate, datctype FROM pg_database;

4. Viewing Connection and Configuration Settings

  • To view settings that affect the PostgreSQL server, and their current values:
  • To find out where the PostgreSQL data directory is located:
psql -c 'SHOW data_directory;'

These commands help you extract key configuration parameters and runtime settings.

5. Using System Administration Tools

Tools like top, htop, netstat, or ps can also provide indirect insights about the PostgreSQL processes, such as memory and CPU usage, and network connections respectively.

By using these methods, you can effectively gather valuable information about your PostgreSQL cluster's configuration and operational status.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book
Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.