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
Redshift has very fast I/O, so that opeation should take less than 1 second for any cluster type or size. As diemacht said, the issue is caused because you have another connection with an open transaction.
I had a similar issue: A crash on the client left a transaction 'open' but unreacheable.
No db locks appeared on the STV_LOCKS table: (using select table_id, last_update, lock_owner, lock_owner_pid from stv_locks;
)
Also, no query was still running: (checked with: select pid, trim(user_name), starttime, query , substring(query,1,20), status from stv_recents where status='Running';
)
So the solution was to list the user sessions: SELECT * FROM STV_SESSIONS
And then kill it using: SELECT pg_terminate_backend(pid)
Or the KILL'EM ALL version:
SELECT pg_terminate_backend(process) FROM STV_SESSIONS where user_name='user_name' and process != pg_backend_pid();
Note that CANCEL {pid}
did not work! (the query was cancelled but the transaction was still open and locking).