agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: drh@sqlite.org
To: pgsql-docs@lists.postgresql.org
Subject: Re: CLUSTER command
Date: Wed, 16 Oct 2024 11:22:48 +0200
Message-ID: <202410160922.cahfnhjlhawv@alvherre.pgsql> (raw)
In-Reply-To: <172898828398.700.17746720152307042879@wrigleys.postgresql.org>

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





view thread (3+ messages)  latest in thread

Message-ID: <202410160922.cahfnhjlhawv@alvherre.pgsql>
Permalink:  ../202410160922.cahfnhjlhawv@alvherre.pgsql/
Also on:    postgresql.org/message-id/202410160922.cahfnhjlhawv@alvherre.pgsql

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: alvherre@alvh.no-ip.org, drh@sqlite.org, pgsql-docs@lists.postgresql.org
  Subject: Re: CLUSTER command
  In-Reply-To: <202410160922.cahfnhjlhawv@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox