Re: pg_dump is broken for partition tablespaces
От | Alvaro Herrera |
---|---|
Тема | Re: pg_dump is broken for partition tablespaces |
Дата | |
Msg-id | 20190409133036.GA30290@alvherre.pgsql обсуждение исходный текст |
Ответ на | Re: pg_dump is broken for partition tablespaces (Andres Freund <andres@anarazel.de>) |
Список | pgsql-hackers |
On 2019-Mar-06, Andres Freund wrote: > > I also find it far from clear that: > > <listitem> > > <para> > > The <replaceable class="parameter">tablespace_name</replaceable> is the name > > of the tablespace in which the new table is to be created. > > If not specified, > > <xref linkend="guc-default-tablespace"/> is consulted, or > > <xref linkend="guc-temp-tablespaces"/> if the table is temporary. For > > partitioned tables, since no storage is required for the table itself, > > the tablespace specified here only serves to mark the default tablespace > > for any newly created partitions when no other tablespace is explicitly > > specified. > > </para> > > </listitem> > > is handled correctly. The above says that the *specified* tablespaces - > > which seems to exclude the default tablespace - is what's going to > > determine what partitions use as their default tablespace. But in fact > > that's not true, the partitioned table's pg_class.retablespace is set to > > what default_tablespaces was at the time of the creation. > > I still think the feature as is doesn't seem to have very well defined > behaviour. I have just started looking into this issue. I'm not sure yet what's the best fix; maybe for the specific case of partitioned tables and indexes we should deviate from the ages-old behavior of storing zero tablespace, if the tablespace is specified as the default one. But I haven't written the code yet. In the meantime, here's David's patch, rebased to current master and with the pg_upgrade and pg_dump tests fixed to match the new partition creation behavior. > > If we instead did: > > > > CREATE TABLE public.listp1 (a integer > > ); > > > > ALTER TABLE public.list1 ATTACH PARTITION public.listp FOR VALUES IN (1); > > Isn't that a bit more expensive, because now the table needs to be > scanned for maching the value? That's probably neglegible though, given > it'd probably always empty. I think it's always empty. In the standard case, there are two transactions rather than one, so yeah it's a little bit more expensive. Maybe we should make this conditional on there actually being an important tablespace distinction to preserve. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Вложения
В списке pgsql-hackers по дате отправления: