-
Hello, I have a weekly partitioned table but I didn't know that
How do I fix it? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 8 replies
-
It means you have data in your default partition that either needs to be moved to the proper child or deleted if it is bad data. You can move the data with the |
Beta Was this translation helpful? Give feedback.
-
@keithf4, just so that I understand (since I can't afford to lose the data), if I run select partman.partition_data_time('public.hist', 1000); It will take data from default partition, 1000 rows at a time, and push them into the target partition table (creating them as necessary). The tables (default and target) will be locked during the batch of 1000 but that lock will be released after batch completion. Before the next batch, a new lock will be acquired and the process will repeat. Is my understanding correct? |
Beta Was this translation helpful? Give feedback.
-
After reading the documentation further, the following seems to be a better command.
I am using PG 12, so, |
Beta Was this translation helpful? Give feedback.
-
It ran mostly successfully but did generate the following error after batch
Any suggestions? |
Beta Was this translation helpful? Give feedback.
-
I am looking at the documentation
The second seems to be the interval while the third is the batch count. Note that I switched to |
Beta Was this translation helpful? Give feedback.
-
My understanding is that the issue is related to the current week where the data is being inserted into the default and it isn't able to create a corresponding weekly partition. Perhaps the problem can be solved by skipping the current weekly partition and creating future weekly partitions. Once, the new data starts going to a new weekly partition, the current week's data can be sent to appropriate partitions by another call to Would it work? |
Beta Was this translation helpful? Give feedback.
-
How do I create a future partitions without creating the current one? Do I just create them manually? |
Beta Was this translation helpful? Give feedback.
-
I created the next weekly tables. Keeping this thread open till next week. Hopefully, everything works fine then. |
Beta Was this translation helpful? Give feedback.
-
I reran
successfully. |
Beta Was this translation helpful? Give feedback.
It means you have data in your default partition that either needs to be moved to the proper child or deleted if it is bad data.
You can move the data with the
partition_data_*()
functions or procedure. This will create any necessary child tables to hold that data, but note it requires a lock on those rows because it has to move that data around between tables. Also note that if it creates a child table far ahead of the existing latest one, you may have a gap in the sequence of child tables. That gap can be filled with thepartition_gap_fill()
function.