pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
New tablespace: just an advice
3+ messages / 2 participants
[nested] [flat]

* New tablespace: just an advice
@ 2018-10-15 12:48  Moreno Andreo <moreno.andreo@evolu-s.it>
  0 siblings, 1 reply; 3+ messages in thread

From: Moreno Andreo @ 2018-10-15 12:48 UTC (permalink / raw)
  To: pgsql-general

Hi everyone!

My space on my Debian 8 DB server is running a bit low (10% left of a 
2TB disk), so, since it's not possible to have a primary MBR disk with 
size > 2 TB, I decided to create another disk and map it on the server, 
creating another tablespace on it and moving databases aross disks to 
balance disk usage.

After creating a test server on this night's production server image, I 
created a folder and assigned ownership to postgres user
mkdir /newdisk/tbsp_new
chown -R postgres /newdisk/tbsp_new

then created new tablespace
create tablspace tb2 location '/newdisk/tbsp_new';

and moved a database
alter database db set tablespace tb2;

As you can see a flat, basic tablespace with no customizations.
I just ran a VACUUM FULL on the cluster before creating tablespace.
After the ALTER DATABASE command ran successful, I checked disk space 
(df -h) and saw some more free space on primary disk, and the same space 
occupied on new disk. Just what I needed.
I psql'd in the cluster with the user's username connecting on the 
database just migrated, and was able to SELECT and UPDATE (not tried 
INSERTing).

Now, 2 questions.
1. Is it all or do I need to adjust something else about permissions, 
indexes, vacuuming, etc...?
ALTERing the database namespace means copying its physical files to new 
directory, but is it applied to all objects (indexes, triggers, etc)?

2. What will happen to who tries to access the database while it's being 
moved from one tablespace to another?

Thanks in advance,
Moreno.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: New tablespace: just an advice
@ 2018-10-16 08:18  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Moreno Andreo <moreno.andreo@evolu-s.it>
  0 siblings, 1 reply; 3+ messages in thread

From: Laurenz Albe @ 2018-10-16 08:18 UTC (permalink / raw)
  To: Moreno Andreo <moreno.andreo@evolu-s.it>; pgsql-general

Moreno Andreo wrote:
> Now, 2 questions.
> 1. Is it all or do I need to adjust something else about permissions, 
> indexes, vacuuming, etc...?
> ALTERing the database namespace means copying its physical files to new 
> directory, but is it applied to all objects (indexes, triggers, etc)?

All objects that are located in the default tablespace of the database
will be moved.

> 2. What will happen to who tries to access the database while it's being 
> moved from one tablespace to another?

They will be "hanging" with a lock until the transaction is done.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: New tablespace: just an advice
@ 2018-10-16 09:13  Moreno Andreo <moreno.andreo@evolu-s.it>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 0 replies; 3+ messages in thread

From: Moreno Andreo @ 2018-10-16 09:13 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Il 16/10/2018 10:18, Laurenz Albe ha scritto:
> Moreno Andreo wrote:
>> Now, 2 questions.
>> 1. Is it all or do I need to adjust something else about permissions,
>> indexes, vacuuming, etc...?
>> ALTERing the database namespace means copying its physical files to new
>> directory, but is it applied to all objects (indexes, triggers, etc)?
> All objects that are located in the default tablespace of the database
> will be moved.
>
>> 2. What will happen to who tries to access the database while it's being
>> moved from one tablespace to another?
> They will be "hanging" with a lock until the transaction is done.
>
> Yours,
> Laurenz Albe

Perfect!

Thanks for your time,

Moreno






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-10-16 09:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-15 12:48 New tablespace: just an advice Moreno Andreo <moreno.andreo@evolu-s.it>
2018-10-16 08:18 ` Laurenz Albe <laurenz.albe@cybertec.at>
2018-10-16 09:13   ` Moreno Andreo <moreno.andreo@evolu-s.it>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox