0

I have partitioned tables in postgresql. With some of them everything is fine and partitions are created. But with some of them there are problems. When I start a transaction to create a partition it does not end, but lasts indefinitely.The transaction took more than enough time to complete - about 12 hours. But after 10 minutes of this transaction execution there is a big load on the database, because of which the applications cannot access the database. Some info about tables

  • All tables are partitioned by date. The tables are small in size, about 3 GB. Those tables that have partitions created have a slightly smaller size. I have several other servers with the same database template. But everything works fine for them.

  • This database is just a backup of one of the two, where everything works fine.

  • Partitions are not created either through the postgres role or the second role that has permissions.

  • Currently, fine databases have postgresql 14 on them, and postgresql 11 on the problematic one, but even at the moment when other servers had version 11, everything worked.

What I try to do:

  • I have not found any locks during the execution of the transaction.

  • I have also stopped the applications that use the database. This did not help either.

  • I tried to create partition through a regular script and DBeaver.

  • There are no errors in the database logs.

5
  • you really want a partition for every date on every table? Why do you want or need that ?
    – nbk
    Commented Sep 3 at 9:59
  • It's archived data. Based on this data I make many equations. It's been working more than 6 years this way. Just need to another company and we engage with this sitation there. Commented Sep 3 at 10:04
  • What exactly is the SQL statement to create the partition? How does pg_stat_activity look when there is a "big load" while creating the partition hangs? Commented Sep 3 at 13:54
  • @Laurenz Albe, just usual script - "CREATE TABLE table_2024_09 PARTITION OF table FOR VALUES FROM ('2024-09-01 00:00:00+04') TO ('2024-10-01 00:00:00+04')". During transaction pg_stat_activity show that transaction is active. And even pg_stat_activity executed long Commented Sep 4 at 4:49
  • Please edit the question and put the statement there. Also add the output of SELECT pid, state, wait_event_type, wait_event, query FROM pg_stat_activits WHERE state <> 'idle';. Commented Sep 4 at 6:26

0

Your Answer

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

Browse other questions tagged or ask your own question.