Thread: 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? Thanks. -Tony '
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, Pennsylvania19026
>> 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
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