Julien Grenier
Julien Grenier

Reputation: 3394

Why would a SQL drop statement give a timeout

I am trying to drop some tables in a Postgres database. For some of those table I am getting a transaction timeout (even where they are empty).

This is my table

CREATE TABLE many_2_many_table (
id integer NOT NULL,
object_1_id integer NOT NULL,
object_2_id integer NOT NULL);

id is a primary key and both object_1_id and object_2_id are foreign key.

Now the table is empty and I want to drop it. Both Drop and Truncate are giving me transation timeout. I have been able to drop it and my other postgres environnements. The timeout is after 30 seconds.

Upvotes: 5

Views: 4296

Answers (1)

Frank Heikens
Frank Heikens

Reputation: 127396

Check pg_locks and pg_stat_activity to see if the table is still in use by some proces.

Upvotes: 10

Related Questions