naveen nani

Posted on 23rd June 2024|39 views


Postgresql Tablespace Location

What is the Tablespace location in PostgreSQL?

1 answers
kumar san

Posted on 23rd June 2024| views

  1. A Tablespace is a simple command used by the PostgreSQL server as it defines locations for the files holding database objects.
  2. Tablespace gives a privilege to the superuser to control the layout of the disk.
  3. A tablespace used to increase the performance by storing the most used data on the available high-speed drive, and least used data on the slow disk as this can optimise the performance of the database objects.
  4. Users use the tablespace for Fast indexes, database growth and data compression. 

Creating a tablespace Syntax:

CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data'; 

Above syntax creates a tablespace which will allocate file locations which holds database objects.

By default, once we create a tablespace, then it creates two dataspaces:

Pg_global: it is used for shared systems when the database cluster initialised.

Pg_default: it creates default tablespace as template1, template0.


Tablespace functions as this is a very efficient feature in PostgreSQL as this can use for data backup(pg_basebackup), Creating, moving and making temporary objects and so on.


Write your answer


Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Course *
Email *
Phone Number