DEV Community

Discussion on: How can I stop a PostgreSQL query automatically when the table is locked?

Collapse
 
siscia_ profile image
Simone Mosciatti

That is kinda never going to work.

Have you tried to lock the table first and then doing the partition?

postgresql.org/docs/9.4/sql-lock.html

LOCK with the NOWAIT option.

Of course this won't block but the table won't be partitioned, so you may need to put some control mechanism in place. (Aka put it into a loop).

Said so, locks are fundamental in postgres, I would suggest you to refresh how and why they work.

Collapse
 
barbaraips profile image
Bárbara Perdigão • Edited

Thanks for replying. I'm actually fairly new to postgres, so I'm struggling a with some concepts. I actually solved the problem by setting a timeout for the Linux command, not for the query, this way I'll not interfere with the locked table.