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

Question - Why should sub-partition interval be smaller than parent interval #695

Open
fobbing opened this issue Oct 3, 2024 · 6 comments
Assignees
Milestone

Comments

@fobbing
Copy link

fobbing commented Oct 3, 2024

I have a requirement to create ID partition and sub-partitions.

If I partition the top level using list partitioning with an interval of 1 (each partition will represent a customer), I am unable to create a sub-partition on a different column which also has interval of 1.

The error I receive is:
Sub-partition interval cannot be greater than or equal to the given parent interval

I'd like to understand the reasoning behind this, are there any foot guns I'm not seeing?

@keithf4
Copy link
Collaborator

keithf4 commented Oct 3, 2024

Good point. As long as the columns are different, should be able to have different intervals. I'll have to see about fixing that.

This has generally been considered that the subpartition would be on the same column as the parent. In that case it wouldn't make any sense.

@keithf4 keithf4 self-assigned this Oct 3, 2024
@fobbing
Copy link
Author

fobbing commented Oct 4, 2024

Good point. As long as the columns are different, should be able to have different intervals. I'll have to see about fixing that.

This has generally been considered that the subpartition would be on the same column as the parent. In that case it wouldn't make any sense.

Aah, thank you. I hadn't considered sub-partitioning on the same column as the parent.
The limitation makes perfect sense in that context.

I assume this would be a matter of adding an additional check in the conditionals in create_sub_parent() to make sure the control columns are the same before enforcing the limitation?

@keithf4
Copy link
Collaborator

keithf4 commented Oct 4, 2024

That was my intention to try

@keithf4
Copy link
Collaborator

keithf4 commented Oct 4, 2024

I already check if they're the same data type here.

https://github.com/pgpartman/pg_partman/blob/master/sql/functions/create_sub_parent.sql#L117

Would be another check to ensure they're the same column

@fobbing
Copy link
Author

fobbing commented Oct 7, 2024

On further inspection I see that the current rule is enforced in a few functions, not only create_sub_parent().

I'd hoped it was limited to create_sub_parent(), I'm not so confident about hacking in a lot of places.

@keithf4
Copy link
Collaborator

keithf4 commented Oct 16, 2024

I'll definitely work on getting this fixed, but I don't think it will make it into the next release at this point.

@keithf4 keithf4 added this to the Future milestone Oct 16, 2024
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