Jun 5, 2022

Tablespace in PostgreSQL

 

Tablespace

In PostgreSQL, tablespaces enable administrators to specify places in the file system where files representing database objects can be kept. When generating database objects, a tablespace can be referred to by name once it has been created.

By using tablespaces, an administrator can control the disk layout of a PostgreSQL installation. This is useful in at least two ways. 

First, if the partition or volume on which the cluster was initialized runs out of space and cannot be extended, a tablespace can be created on a different partition and used until the system can be reconfigured.

Second, tablespaces allow an administrator to use knowledge of the usage pattern of database objects to optimize performance.

 For example, an index which is very heavily used can be placed on a very fast, highly available disk, such as an expensive solid state device. At the same time a table storing archived data which is rarely used or not performance critical could be stored on a less expensive, slower disk system.

Tablespace Creation 

create tablespace ts1 location '/var/lib/pgsql/13/data/myTS';

Creating Table on a Tablespace

create table i3_newdpt(dpt_id int) tablespace ts1;


No comments:

Post a Comment

If you have any doubt or question, please contact us.