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