PostgreSQL: Create or Change default Tablespace of Table to Migrate on SSD

My Problem:

In our Windows based PostgreSQL Server, We were facing Hard disk related performance issue. Later, we decided to move some of our main tables on SSD Hard Disk (Solid State Drive).

The Performance of SSD Hard drive is 10 times faster than normal HDD Disk.

The Solution:

First, We have to create new Tablespace on SSD disk. The pg_default is a default Tablespace in PostgreSQL. A Tablespace contains all Table information and data.

In PostgreSQL, We can create a new Tablespace or we can also alter Tablespace for existing Tables.
We can perform this exercise using both PGAdmin tool and Script.

In below example, I am creating and changing Tablespace using script.


Create a sample Tablespace:

Create a new table under newly created Tablespace:

We can also change default Tablespace:
After this change, all your newly table can create under dbrnd Tablespace.

Create one more table and test this:

Change Tablespace of existing Table:

Check all Tablespace of your PostgreSQL Database Server:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of