Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-key index columns are not properlly inherited from template table #674

Open
C0mbatwombat opened this issue Jul 14, 2024 · 1 comment

Comments

@C0mbatwombat
Copy link

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!

@keithf4
Copy link
Collaborator

keithf4 commented Jul 15, 2024

Thanks for the report. Looks like a valid issue but I'll need to investigate more when I get back to working on the next version of partman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants