pg_global pg_global#

What is pg_global in PostgreSQL?#

pg_global is a special PostgreSQL tablespace that stores cluster-wide system metadata shared by all databases in the server.

In short: pg_global stores PostgreSQLโ€™s brain โ€” not your data.

pg_global is the PostgreSQL system tablespace that contains global catalog tables shared across all databases in a PostgreSQL cluster.


๐Ÿ“‚ Where pg_global Lives#

On disk:

$PGDATA/global/

This directory is outside individual databases.

Unlike pg_default, it is:
  • Not per-database

  • Shared across the entire cluster


What is Stored in pg_global?#

pg_global contains cluster-wide system catalogs, including:

Authentication & Roles
  • Users (roles)

  • Password hashes

  • Role privileges

Database Metadata
  • List of all databases

  • Database ownership

  • Encoding, locale info

Tablespaces
  • Tablespace definitions

  • Physical paths

Replication & Slots
  • Replication slots

  • Subscription metadata

๐Ÿ” Security Objects
  • Access control lists

  • Shared dependencies


Key System Catalog Tables#

Catalog

Purpose

pg_database

List of all databases

pg_authid

Roles & passwords

pg_tablespace

Tablespace info

pg_shdepend

Shared dependencies

These live physically in pg_global.


๐Ÿšซ What is NOT Stored in pg_global
  • โŒ User tables

  • โŒ Indexes

  • โŒ Application data

  • โŒ Schemas

  • โŒ Views

Those belong in pg_default or custom tablespaces.


โš ๏ธ Why pg_global Is Untouchable
  • Required for PostgreSQL startup

  • Shared by all databases

  • Corruption = server wonโ€™t start

  • Cannot be dropped

  • Cannot be moved

If pg_global is damaged, all databases are affected.


pg_default vs pg_global#

Feature

pg_default

pg_global

Scope

Per database

Cluster-wide

Stores user data

โœ…

โŒ

Stores system catalogs

โŒ

โœ…

Safe to use manually

โœ…

๐Ÿšซ

Can be customized

โœ…

โŒ


Real-World Analogy#

Think of PostgreSQL as a company:

PostgreSQL

Company

pg_global

HR + Admin office

pg_default

Department offices

Databases

Departments

Tables

Files

You never edit HR records directly โ€” same with pg_global.


Why pgAdmin Shows pg_global#

pgAdmin shows it so you:
  • Understand cluster structure

  • Can inspect (read-only)

  • Donโ€™t accidentally misuse it

Viewing is safe. Editing is not.

Backup Importance#

Every full PostgreSQL backup must include pg_global.

Example:

pg_dumpall --globals-only > globals.sql
This backs up:
  • Roles

  • Tablespaces

  • Global privileges

Summary#

Note

pg_global is PostgreSQLโ€™s system tablespace that stores global metadata shared across all databases, including roles, databases, tablespaces, and security information. It is essential for server operation and should never be modified manually.