A tablespace is a location on disk where PostgreSQL stores data
files containing database objects e.g., indexes., tables, etc.
PostgreSQL uses a tablespace to map a logical name to physical
location on disk.
PostgreSQL comes with two default tablespaces:
pg_default
tablespace stores all user data.
pg_global
tablespace stores all global data.
The tablespaces allows you to control the disk layout of
PostgreSQL. There are two main advantages of using tablespaces:
- First, if a partition on which the cluster was initialized
is out of space, you can create a new tablespace on a different
partition and use it until you reconfigure the system.
- Second, you can use the statistics of database objects’
usages to optimize the performance of databases. For example,
the you can place the frequent access indexes or tables on
devices that perform very fast e.g., solid state devices, and
put the tables containing archive data which is rarely used on a
slower devices.