Re: Suggestion: Explain how to move objects to the default tablespace in sql-altertable.html

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Holger Jakobs <holger(at)jakobs(dot)com>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Suggestion: Explain how to move objects to the default tablespace in sql-altertable.html
Date: 2021-12-01 15:44:35
Message-ID: CAKFQuwbB0JZ63yU7-XwTgOZfmeYXG1pVd+KZkU8uKY3LVpgP2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Dec 1, 2021 at 8:14 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
wrote:

> On Wed, 2021-12-01 at 15:37 +0100, Holger Jakobs wrote:
> > Today I wanted to move an object to the unnamed defaul tablespace. It
> > took me a while to find out that neither the empty string '' nor the
> > word default works, but that you have to use pg_default.
> >
> > This should be mentioned in the documentation of the ALTER TABLE command
> > (and maybe others).
>
> Not sure if that is necessary. You have to use the name of the tablespace.
> You can see that with "\db" in psql or query "pg_tablespace".
>
> That's no different from other tablespaces...
>
>
The documentation flow for the common case described here is:

ALTER TABLE ->
CREATE TABLE (which is not linked to from the ALTER TABLE TABLESPACE clause
entry) ->
default_tablespace GUC (which is directly linked to) ->
Read that if the GUC value is the empty string (typical) that the database
default is used ->
Now link over to 23.6 (Managing Databases - Tablespaces) to learn that the
specific value of the tablespace for the database is "pg_default" ->
And since other tablespaces are seemingly in use perform further research
using the 23.6 information to check exactly what is the current database
default is

I'm not quite sold on "the status quo is great" based upon that chain of
reading. Especially since default_tablespace is content on returning an
empty string as opposed to a tablespace name.

I don't have a problem updating CREATE TABLE to be more detailed, and then
(maybe) update ALTER TABLE to more directly reference CREATE TABLE if one
needs to learn about choosing a valid value for changing the tablespace
name to the database default. Or, maybe skip the GUC page and link
directly to 23.6 in both and improve the description provided therein. But
saying that ALTER TABLE is the primary problem spot seems biased by the
specific report. ALTER pages are rarely the place to be learning about how
different features work - the CREATE page is the primary entry point, and
by that general policy there is probably no pressing need to make the ALTER
TABLE page directly link to CREATE TABLE in this specific situation (or
even point to default_tablespace or even 23.6 directly).

David J.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Holger Jakobs 2021-12-01 15:49:44 Re: Suggestion: Explain how to move objects to the default tablespace in sql-altertable.html
Previous Message Laurenz Albe 2021-12-01 15:14:42 Re: Suggestion: Explain how to move objects to the default tablespace in sql-altertable.html