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.