Re: CLUSTER command

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: drh(at)sqlite(dot)org, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: CLUSTER command
Date: 2024-10-16 09:22:48
Message-ID: 202410160922.cahfnhjlhawv@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hello,

On 2024-Oct-15, PG Doc comments form wrote:

> The documentation does not say what happens if you do "CLUSTER tablename"
> and omit the USING clause, which is shown as optional in the BNF, if I'm
> reading it right. Does CLUSTER use the PRIMARY KEY in that case? What if
> no PRIMARY KEY is specified?

The table is clustered on the index that was previously selected as the
cluster index (either by running "CLUSTER table ON idx" or by doing
ALTER TABLE tab CLUSTER ON idx"). If no index is selected, an error is
thrown.

The docs explain it this way:

When a table is clustered, PostgreSQL remembers which index it was clustered
by. The form CLUSTER table_name reclusters the table using the same index as
before. You can also use the CLUSTER or SET WITHOUT CLUSTER forms of ALTER
TABLE to set the index to be used for future cluster operations, or to clear
any previous setting.

I'm not sure if we need to make this clearer. It's perfectly clear to
me, but then I already knew what I wanted to read ...

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"After a quick R of TFM, all I can say is HOLY CR** THAT IS COOL! PostgreSQL was
amazing when I first started using it at 7.2, and I'm continually astounded by
learning new features and techniques made available by the continuing work of
the development team."
Berend Tober, http://archives.postgresql.org/pgsql-hackers/2007-08/msg01009.php

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Richard Hipp 2024-10-16 09:37:29 Re: CLUSTER command
Previous Message Peter Eisentraut 2024-10-16 07:07:13 Re: Limitation relates to memory allocation