redshift drop or truncate table very very slow

后端 未结 4 1849
轻奢々
轻奢々 2021-01-30 03:50

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

4条回答
  •  离开以前
    2021-01-30 04:54

    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.

提交回复
热议问题