Tablespace

A location outside of the main data directory for storing data

A tablespace is a location outside of the main data directory for storing data. This enables the distribution of data over multiple file systems, for example for storing more frequently accessed data on faster storage, or splitting table data and indexes between different disks.

Tablespaces were introduced in PostgreSQL 8.0 (commit 2467394e).

psql commands

  • \db lists basic information about tablespaces available to a cluster
  • \db+ displays additional information such as tablespace size

System catalogue

Tablespace information is stored in the system catalogue table pg_tablespace.

Configuration

Following configuration parameters affect tablespace usage:

  • default_tablespace: default tablespace in which to create (non-temporary) objects (tables and indexes) when not overridden by the CREATE command or the database's default tablespace setting
  • temp_tablespaces: list of tablespaces in which to create temporary objects

Tablespace functions

Following functions provide tablespace-related information:

Categories

Management / adminstration, Storage, Tablespaces

See also

CREATE TABLESPACE, ALTER TABLESPACE, DROP TABLESPACE, tablespace directory, pg_tablespace