Unix Technical Forum

Moving a table to another directory

This is a discussion on Moving a table to another directory within the pgsql Admins forums, part of the PostgreSQL category; --> Hi guys I have a big table (25 gb) and a need to move it to another directory cos ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 07:09 AM
Ezequiel Luis Pellettieri
 
Posts: n/a
Default Moving a table to another directory

Hi guys I have a big table (25 gb) and a need to move it to another
directory cos i'm out of space.
making a symlik will be ok? or I have to do something else

thanks in advance!

pelle.-

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 07:09 AM
Milen A. Radev
 
Posts: n/a
Default Re: Moving a table to another directory

Ezequiel Luis Pellettieri написа:
> Hi guys I have a big table (25 gb) and a need to move it to another
> directory cos i'm out of space.
> making a symlik will be ok? or I have to do something else
>



1. CREATE TABLESPACE xxx LOCATION 'another_dir'
(http://www.postgresql.org/docs/curre...lespace.html);

2. ALTER TABLE big_table SET TABLESPACE xxx;
(http://www.postgresql.org/docs/curre...ltertable.html)


--
Milen A. Radev


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 07:09 AM
Jaime Casanova
 
Posts: n/a
Default Re: Moving a table to another directory

> 2007/2/5, Milen A. Radev <milen@radev.net>:
> > Ezequiel Luis Pellettieri :
> > > Hi guys I have a big table (25 gb) and a need to move it to another
> > > directory cos i'm out of space.
> > > making a symlik will be ok? or I have to do something else
> > >

> >
> >
> > 1. CREATE TABLESPACE xxx LOCATION 'another_dir'
> > (

> http://www.postgresql.org/docs/curre...lespace.html);
> >
> > 2. ALTER TABLE big_table SET TABLESPACE xxx;
> >

> (http://www.postgresql.org/docs/curre...ltertable.html
> )
> >

On 2/5/07, Ezequiel Luis Pellettieri <ezequiel.pellettieri@gmail.com> wrote:
> Thanks Milen, does it work on 7.4??
>


oops... your symlink will be ok... use the contrib oid2name to
identify the files corresponding to that table... and maybe the
indexes as well...

what i remember from the ancient era pre-tablespace (2 or 3 years ago)
is that a pg_dump and/or reindex will return all to it's original
state...

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 07:09 AM
Jaime Casanova
 
Posts: n/a
Default Re: Moving a table to another directory

On 2/5/07, Ezequiel Luis Pellettieri <ezequiel.pellettieri@gmail.com> wrote:
> Jaime you mean that moving all table files and pointing the symlink to the
> first one will work?
> and doing the same with its index too...?
>


no, IIRC, you need a symlink per table's file, the same for index's files...
you shoukd think in upgrading...

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 07:09 AM
Scott Marlowe
 
Posts: n/a
Default Re: Moving a table to another directory

On Mon, 2007-02-05 at 21:03, Jaime Casanova wrote:
> > 2007/2/5, Milen A. Radev <milen@radev.net>:
> > > Ezequiel Luis Pellettieri написа:
> > > > Hi guys I have a big table (25 gb) and a need to move it to another
> > > > directory cos i'm out of space.
> > > > making a symlik will be ok? or I have to do something else
> > > >
> > >
> > >
> > > 1. CREATE TABLESPACE xxx LOCATION 'another_dir'
> > > (

> > http://www.postgresql.org/docs/curre...lespace.html);
> > >
> > > 2. ALTER TABLE big_table SET TABLESPACE xxx;
> > >

> > (http://www.postgresql.org/docs/curre...ltertable.html
> > )
> > >

> On 2/5/07, Ezequiel Luis Pellettieri <ezequiel.pellettieri@gmail.com> wrote:
> > Thanks Milen, does it work on 7.4??
> >

>
> oops... your symlink will be ok... use the contrib oid2name to
> identify the files corresponding to that table... and maybe the
> indexes as well...
>
> what i remember from the ancient era pre-tablespace (2 or 3 years ago)
> is that a pg_dump and/or reindex will return all to it's original
> state...


Note that you've also got the option of using initlocation. This only
allows you to create entire databases on alternate storage location, not
individual tables.

If you DO go with symlinks, certain operations may result in losing the
link and recreating the table in the local directory (i.e. anything that
would change the OID assigned to that table, as I believe cluster and
reindex would do)

See
http://www.postgresql.org/docs/7.4/s...tlocation.html
and
http://www.postgresql.org/docs/7.4/s...edatabase.html

But my primary recommendation is to upgrade to AT LEAST 8.1 version of
PostgreSQL. Now that 8.2.2 is out, I'd consider going to it. 7.4 is
getting pretty long in the tooth by comparison.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 07:10 AM
Jaime Casanova
 
Posts: n/a
Default Re: Moving a table to another directory

On 2/7/07, Ezequiel Luis Pellettieri <ezequiel.pellettieri@gmail.com> wrote:
> thanks guys, is it possible to go with it, without stopping the postmaster?
> maybe just rejecting conns to the DB...
> this is cos I had another DB's running...
>
> thanks again.
>


AFAIR, no

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com