1

I'm trying to make dynamic partitions in Postgres. What am I trying to achieve: I will have tableA that will have a lot of data and will have a column with some_id which will be heavily used in where statement. So, my plan is to have partition by list with some_id value. How to achieve dynamic partitioning, So when new id is inserted partition is dynamically created?

2 Answers 2

1

There is no way to do that in PostgreSQL currently.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. What about a bit hardcoding with trigger? Would that be considered as good practice?
I tried, and it doesn't work. Basically, a trigger that is run from an action on a table cannot modify the table's definition.
0

The best possible way to do it currently is through code. Since trigger cannot change table definition the best approach would be to do execute a statement after through a backend after insert.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.