Re: Should I CLUSTER on PRIMARY KEY

From: Chris <dmagick(at)gmail(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Should I CLUSTER on PRIMARY KEY
Date: 2009-07-20 00:21:44
Message-ID: 4A63B898.8080700@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert James wrote:
> I would like to CLUSTER a table on its PRIMARY KEY. Now, I haven't
> explicitly defined and named an index for this table - but the primary
> key defines one. How can I tell Postgres to CLUSTER on it?

Get the index name:

\d tablename

Right at the bottom it will have the index names:

Indexes:
"a_pkey" PRIMARY KEY, btree (a)

then cluster:

# cluster tablename using a_pkey;
CLUSTER

> Also: If I define an index on a PK, will Postgres make a second one, or
> realize its redundnant?

Depends how you define it (I think). What's your create table statement
look like?

--
Postgresql & php tutorials
http://www.designmagick.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2009-07-20 00:26:21 Re: [PERFORM] Incr/Decr Integer
Previous Message Adrian Klaver 2009-07-20 00:15:12 Re: timestamp with time zone tutorial