Re: Index File locations

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Index File locations
Date: 2010-08-27 22:36:03
Message-ID: 4C783DD3.9000106@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 08/27/10 8:43 AM, A. Kretschmer wrote:
> In response to Callum Scott :
>> Hi All,
>>
>> I am looking for a way to define where index files should be located.
>>
>> I am wanting to store the index files on a separate SSD from the database
>> itself. I can see that there is a way to define this from within the
>> database. Is there a way to do this at a system level within the configuration
>> file?
> You have to define a own tablespace and then you can create new indexes
> on this tablespace.
>
> test=# \h create tablespace
> Command: CREATE TABLESPACE
> Description: define a new tablespace
> Syntax:
> CREATE TABLESPACE tablespacename [ OWNER username ] LOCATION 'directory'
>
> test=# \h create index
> Command: CREATE INDEX
> Description: define a new index
> Syntax:
> CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] name ON table [ USING method ]
> ( { column | ( expression ) } [ opclass ] [ ASC | DESC ] [ NULLS {
> FIRST | LAST } ] [, ...] )
> [ WITH ( storage_parameter = value [, ... ] ) ]
> [ TABLESPACE tablespace ]
> [ WHERE predicate ]
>

you can also ALTER INDEX indexname SET TABLESPACE tablespacename;

this will move the existing index to the specified tablespace.

note that you want to do this when your applications are quiescent as
this will require an exclusive access lock for the duration of the move.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jon Griffin 2010-08-28 01:48:40 plpgsql question
Previous Message Jason Dixon 2010-08-27 19:33:55 Surge 2010 Early Registration ends Tuesday!