When drop or truncate a not too big table(4M rows) in my redshift database, it take very very long(hours) to complete. Does anybody experience the same issue?
Thanks
In my experience, as @Gerardo Grignoli says, locks don't show up in the stv_locks
table, but they do show up in pg_locks
. Depending on your environment it may not be acceptable to kill an arbitrary long-running session listed in stv_sessions
. I find the pg_locks
table to be very reliable for detecting this type of lock:
select * from pg_locks where relation = (select oid from pg_class where relname = 'the_table')
select pg_cancel_backend(pid)
Typically, the issue is an ACCESS EXCLUSIVE
lock that's deadlocking the table. So, if many locks are listed, find and kill the ACCESS EXCLUSIVE
one.