Обсуждение: table inheritance partition and indexes

Поиск
Список
Период
Сортировка

table inheritance partition and indexes

От
Ted Toth
Дата:
I've created a table with a number of indexes and then created a partition table that inherits from it using "CREATE TABLE... INHERITS..." . I've then queried pg_indexes on the parent for its indexes and tried creating matching indexes on the child and attaching them to the parent table indexes. However "ALTER TABLE ... ATTACH PARTITION ..." is returning the error "<parent tables index name> is not a table partitioned index". I've followed the inheritance partitioning example and read the "CREATE INDEX" docs but I must be missing something, can anyone help me understand what I'm doing wrong? I'm using version 13.

Ted

Re: table inheritance partition and indexes

От
Ron
Дата:
Out of curiosity, why INHERITS in v13 instead of PARTITION BY?

On 11/23/22 09:31, Ted Toth wrote:
> I've created a table with a number of indexes and then created a partition 
> table that inherits from it using "CREATE TABLE... INHERITS..." . I've 
> then queried pg_indexes on the parent for its indexes and tried creating 
> matching indexes on the child and attaching them to the parent table 
> indexes. However "ALTER TABLE ... ATTACH PARTITION ..." is returning the 
> error "<parent tables index name> is not a table partitioned index". I've 
> followed the inheritance partitioning example and read the "CREATE INDEX" 
> docs but I must be missing something, can anyone help me understand what 
> I'm doing wrong? I'm using version 13.
>
> Ted
>

-- 
Angular momentum makes the world go 'round.



Re: table inheritance partition and indexes

От
Ted Toth
Дата:
Because none of the declarative partition types do what I want.

On Wed, Nov 23, 2022 at 1:24 PM Ron <ronljohnsonjr@gmail.com> wrote:
Out of curiosity, why INHERITS in v13 instead of PARTITION BY?

On 11/23/22 09:31, Ted Toth wrote:
> I've created a table with a number of indexes and then created a partition
> table that inherits from it using "CREATE TABLE... INHERITS..." . I've
> then queried pg_indexes on the parent for its indexes and tried creating
> matching indexes on the child and attaching them to the parent table
> indexes. However "ALTER TABLE ... ATTACH PARTITION ..." is returning the
> error "<parent tables index name> is not a table partitioned index". I've
> followed the inheritance partitioning example and read the "CREATE INDEX"
> docs but I must be missing something, can anyone help me understand what
> I'm doing wrong? I'm using version 13.
>
> Ted
>

--
Angular momentum makes the world go 'round.


Re: table inheritance partition and indexes

От
Tom Lane
Дата:
Ted Toth <txtoth@gmail.com> writes:
> On Wed, Nov 23, 2022 at 1:24 PM Ron <ronljohnsonjr@gmail.com> wrote:
>> Out of curiosity, why INHERITS in v13 instead of PARTITION BY?

> Because none of the declarative partition types do what I want.

Then you're stuck managing it manually.  But ATTACH PARTITION is
not relevant to INHERITS-style partitioning.

            regards, tom lane



Re: table inheritance partition and indexes

От
Ted Toth
Дата:


On Wed, Nov 23, 2022 at 4:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Ted Toth <txtoth@gmail.com> writes:
> On Wed, Nov 23, 2022 at 1:24 PM Ron <ronljohnsonjr@gmail.com> wrote:
>> Out of curiosity, why INHERITS in v13 instead of PARTITION BY?

> Because none of the declarative partition types do what I want.

Then you're stuck managing it manually.  But ATTACH PARTITION is
not relevant to INHERITS-style partitioning.

That's the part that wasn't clear to me, thanks.
 

                        regards, tom lane

Re: table inheritance partition and indexes

От
David Rowley
Дата:
On Thu, 24 Nov 2022 at 11:34, Ted Toth <txtoth@gmail.com> wrote:
>
> On Wed, Nov 23, 2022 at 4:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Then you're stuck managing it manually.  But ATTACH PARTITION is
>> not relevant to INHERITS-style partitioning.
>
> That's the part that wasn't clear to me, thanks.

Would this have been more clear if [1] didn't mention both declarative
partitioning and inheritance partition on the same page? I've wondered
before if we should split that into two separate pages.

David

[1] https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-USING-INHERITANCE



Re: table inheritance partition and indexes

От
Ted Toth
Дата:
Docs can always be better, right ;) When I went back and looked at the page I did realize that the ATTACH INDEX command was only mentioned in the description of declarative partitioning and not in the inheritance section so I should have paid closer attention to the location.

Ted

On Wed, Nov 23, 2022 at 8:13 PM David Rowley <dgrowleyml@gmail.com> wrote:
On Thu, 24 Nov 2022 at 11:34, Ted Toth <txtoth@gmail.com> wrote:
>
> On Wed, Nov 23, 2022 at 4:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Then you're stuck managing it manually.  But ATTACH PARTITION is
>> not relevant to INHERITS-style partitioning.
>
> That's the part that wasn't clear to me, thanks.

Would this have been more clear if [1] didn't mention both declarative
partitioning and inheritance partition on the same page? I've wondered
before if we should split that into two separate pages.

David

[1] https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITIONING-USING-INHERITANCE