Thread: default_tablespace doc and partitioned rels

default_tablespace doc and partitioned rels

From
Justin Pryzby
Date:
commit 87259588d0ab0b8e742e30596afa7ae25caadb18
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:   Thu Apr 25 10:20:23 2019 -0400

    Fix tablespace inheritance for partitioned rels

This doc change doesn't make sense to me:

+++ b/doc/src/sgml/config.sgml
@@ -7356,7 +7356,8 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
        <para>
         This variable specifies the default tablespace in which to create
         objects (tables and indexes) when a <command>CREATE</command> command does
-        not explicitly specify a tablespace.
+        not explicitly specify a tablespace.  It also determines the tablespace
+        that a partitioned relation will direct future partitions to.
        </para>

default_tablespace is a global GUC, so if a partitioned relation "directs"
partitions anywhere, it's not to the fallback value of the GUC, but to its
reltablespace, as this patch wrote in doc/src/sgml/ref/create_table.sgml:

+      the tablespace specified overrides <literal>default_tablespace</literal>
+      as the default tablespace to use for any newly created partitions when no
+      other tablespace is explicitly specified.

Maybe I'm misreading config.sgml somehow ?
I thought it would be more like this (but actually I think <default_tablespace>
shouldn't say anything at all):

+        ... It also determines the tablespace where new partitions are created,
+        if the parent, partitioned relation doesn't have a tablespace set.


-- 
Justin



Re: default_tablespace doc and partitioned rels

From
Alvaro Herrera
Date:
On 2021-Apr-16, Justin Pryzby wrote:

> +++ b/doc/src/sgml/config.sgml
> @@ -7356,7 +7356,8 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
>         <para>
>          This variable specifies the default tablespace in which to create
>          objects (tables and indexes) when a <command>CREATE</command> command does
> -        not explicitly specify a tablespace.
> +        not explicitly specify a tablespace.  It also determines the tablespace
> +        that a partitioned relation will direct future partitions to.
>         </para>
> 
> default_tablespace is a global GUC, so if a partitioned relation "directs"
> partitions anywhere, it's not to the fallback value of the GUC, but to its
> reltablespace, as this patch wrote in doc/src/sgml/ref/create_table.sgml:

Yes, but also the partitioned table's reltablespace is going to be set
to default_tablespace, if no tablespace is explicitly specified in the
partitioned table creation.

A partitioned table is not created anywhere itself; the only thing it
can do, is direct where are future partitions created.  I don't think
it's 100% obvious that default_tablespace will become the partitioned
table's tablespace, which is why I added that phrase.  I understand that
the language might be unclear, but I don't think either of your
suggestions make this any clearer.  Removing it just hides the behavior,
and this one:

> +        ... It also determines the tablespace where new partitions are created,
> +        if the parent, partitioned relation doesn't have a tablespace set.

just documents that default_tablespace will be in effect at partition
CREATE time, but it fails to remind the user that the partitioned table
will acquire default_tablespace as its own tablespace.

Maybe we can reword it in some other way.  "If this parameter is set
when a partitioned table is created, it will become the default
tablespace for future partitions too, even if default_tablespace itself
is reset later" ...??

-- 
Álvaro Herrera                            39°49'30"S 73°17'W
"En las profundidades de nuestro inconsciente hay una obsesiva necesidad
de un universo lógico y coherente. Pero el universo real se halla siempre
un paso más allá de la lógica" (Irulan)



Re: default_tablespace doc and partitioned rels

From
Justin Pryzby
Date:
On Fri, Apr 16, 2021 at 04:19:18PM -0400, Alvaro Herrera wrote:
> Maybe we can reword it in some other way.  "If this parameter is set
> when a partitioned table is created, it will become the default
> tablespace for future partitions too, even if default_tablespace itself
> is reset later" ...??

+1

I'd say:

If this parameter is set when a partitioned table is created, the partitioned
table's tablespace will be set to the given tablespace, and which will be the
default tablespace for partitions create in the future, even if
default_tablespace itself has since been changed.

-- 
Justin



Re: default_tablespace doc and partitioned rels

From
Alvaro Herrera
Date:
On 2021-Apr-16, Justin Pryzby wrote:

> If this parameter is set when a partitioned table is created, the partitioned
> table's tablespace will be set to the given tablespace, and which will be the
> default tablespace for partitions create in the future, even if
> default_tablespace itself has since been changed.

Pushed with very similar wording:

+       <para>
+        If this parameter is set to a value other than the empty string
+        when a partitioned table is created, the partitioned table's
+        tablespace will be set to that value, which will be used as
+        the default tablespace for partitions created in the future,
+        even if <varname>default_tablespace</varname> has changed since then.
+       </para>

I made it a separate paragraph at the end, because I noticed that I had
added the note in an inappropriate place in the earlier commit; the
second paragraph in particular is more general than this one.  Also
looking at that one I realized that we need to talk about the value
being "not the empty string".

I hope it's clear enough now, but if you or anybody have further
suggestion on improving this, I'm listening.

Thanks

-- 
Álvaro Herrera       Valdivia, Chile
"If you have nothing to say, maybe you need just the right tool to help you
not say it."                   (New York Times, about Microsoft PowerPoint)