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.
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.
The Syntax of CREATE TABLESPACE:
CREATE TABLESPACE tablespace_name
Create a sample Tablespace:
CREATE TABLESPACE dbrnd
Create a new table under newly created Tablespace:
CREATE TABLE tbl_Students
(Rno INT, Name CHARACTER VARYING)
We can also change default Tablespace:
After this change, all your newly table can create under dbrnd Tablespace.
SET default_tablespace = dbrnd;
Create one more table and test this:
CREATE TABLE tbl_Employee
(Eno INT, Name CHARACTER VARYING);
Change Tablespace of existing Table:
ALTER TABLE tbl_Employee SET TABLESPACE pg_default;
Check all Tablespace of your PostgreSQL Database Server:
SELECT spcname FROM pg_tablespace;
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.