Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an ALTER TABLE statement that according to pg_stat is "waiting", and I'm wondering if there is an easy fix to allow the statement to execute?

From my limited understanding I think it's a table level lock that isn't releasing. The table pg_locks shows a single AccessExclusiveLock that has its granted column set to f. Running ps aux | grep postgres confirms that there is a postgres ALTER TABLE waiting.

If it helps the statement is one that's been created by the Django ORM (South in particular).


share|improve this question
up vote 1 down vote accepted

There is most probably another transaction open that did a select on that table.

Look for sessions that are " in transaction".

Make sure they end their transaction (so that the sessions shows "" or if you cannot do that, kill them with pg_terminate_backend()

share|improve this answer

If you have a lot of sessions that are in transaction you can use a query to list the processes blocked and the PID these are blocking on.

Make sure you don't run pg_dump while trying to apply your schema migrations.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.