Ubuntu – Postgresql table drop taking very long time

databasepostgresqlUbuntuweb-server

I am kind of new to Postgresql and server administration so I am not quite sure if this is normal behavior or not. Right now I am trying to drop a table with the cascade option.

The command I used was

DROP TABLE library_genre CASCADE;

It's been about half an hour and it is still saying

NOTICE:  drop cascades to constraint radio_logs_entry_genre_id_fkey on table logs_entry

I am not really sure how to check how big the database is, but I can't imagine is being too big. Do you think there could be some sort of corruption that is causing it to take so long.

Any suggestions to figure this out would be greatly appreciated. What sort of commands should I be using to figure out whats going on?

Edit: New Info

I ran this on a pg_dump I did before I tried dropping the table

du -k pg_dump_file

and it gave me 27712. I am not sure what data size it is returning though. If it is kilobytes that is only 27 megabytes and that doesn't seem like it would take so long modify.

Edit #2. I ran top and it looks like postgres isn't really using much CPU or memory.

Best Answer

Dropping your table is cascading through a constraint - Postgres is most likely bound up examining rows in that referencing table to determine what it needs to do about them.

To speed things up you can drop your constraints first, and/or TRUNCATE the table you want to drop.