Why does cluster need the indexname?

Started by G. Anthony Reinaover 25 years ago4 messages
#1G. Anthony Reina
reina@nsi.edu

I'm probably just missing the point, but why do I have to specify the
indexname for cluster if the table already has a primary key? Wouldn't
cluster want to use the primary key for the table (if it exists) anyway?

Thanks.
-Tony
'

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: G. Anthony Reina (#1)
Re: Why does cluster need the indexname?

I guess we could default it if they don't specifiy an index.

I'm probably just missing the point, but why do I have to specify the
indexname for cluster if the table already has a primary key? Wouldn't
cluster want to use the primary key for the table (if it exists) anyway?

Thanks.
-Tony
'

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: Why does cluster need the indexname?

I'm probably just missing the point, but why do I have to specify the
indexname for cluster if the table already has a primary key? Wouldn't
cluster want to use the primary key for the table (if it exists) anyway?

No, you wouldn't necessarily want to cluster on the primary key.
You might be using the primary key to enforce logical consistency,
but be doing most of your actual scans on some secondary index.

I always thought that CLUSTER was being redundant in the other
direction: if you've told it the index name, there's no need to
tell it the base table name. It can find that out from the index.

regards, tom lane

#4G. Anthony Reina
reina@nsi.edu
In reply to: Bruce Momjian (#2)
Re: Why does cluster need the indexname?

Tom Lane wrote:

I always thought that CLUSTER was being redundant in the other
direction: if you've told it the index name, there's no need to
tell it the base table name. It can find that out from the index.

Good point. That would make the most sense:

CLUSTER index_name

if index_name was a primary key to a table, then there's no need to specify
the table.

-Tony