pg.ddx.io  pgpartman/pg_partman GitHub issues and pull requests  
help / color / mirror / Atom feed
From: C0mbatwombat (@C0mbatwombat) <noreply+C0mbatwombat@github.com>
To: pgpartman/pg_partman <noreply+pgpartman-pg_partman@github.com>
Subject: [pgpartman/pg_partman] issue #674: Non-key index columns are not properlly inherited from template table
Date: Sun, 14 Jul 2024 18:21:23 +0000
Message-ID: <gh-pgpartman-pg_partman-674@github.com> (raw)

Hi team,

First of all, thank you for this great extension! 
I noticed that non-key index columns (using the `INCLUDE` keyword) are inherited as normal index columns.

A minimal example:
```
create table example_table (
    id        BIGINT not null,
    some_other_column BIGINT not null,

    insertTime              TIMESTAMPTZ NOT NULL DEFAULT now()

) PARTITION BY RANGE (insertTime);

CREATE TABLE example_table_template (LIKE example_table);
ALTER TABLE public.example_table_template ADD PRIMARY KEY (id) INCLUDE (some_other_column);

SELECT partman.create_parent('public.example_table', 'inserttime', '1 month', p_template_table := 'public.example_table_template', p_premake := 2);

postgres=# \d example_table_template
                     Table "public.example_table_template"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 id                | bigint                   |           | not null | 
 some_other_column | bigint                   |           | not null | 
 inserttime        | timestamp with time zone |           | not null | 
Indexes:
    "example_table_template_pkey" PRIMARY KEY, btree (id) INCLUDE (some_other_column)  <-------

postgres=# \d example_table_p20240501
                    Table "public.example_table_p20240501"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 id                | bigint                   |           | not null | 
 some_other_column | bigint                   |           | not null | 
 inserttime        | timestamp with time zone |           | not null | now()
Partition of: example_table FOR VALUES FROM ('2024-05-01 00:00:00+00') TO ('2024-06-01 00:00:00+00')
Indexes:
    *example_table_p20240501_pkey" PRIMARY KEY, btree (id, some_other_column) <-------

```
I would have expected the index of `example_table_p20240501` to be the same as the index on the `example_table_template` table. Not a huge issue but I thought you might want to know about it.

Thanks!

view thread (13+ messages)  latest in thread

Message-ID: <gh-pgpartman-pg_partman-674@github.com>
Permalink:  ../gh-pgpartman-pg_partman-674@github.com/

 · 


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