redshift drop or truncate table very very slow

后端 未结 4 1865
轻奢々
轻奢々 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:39

    IMO AccessShareLock on tables also causes DDL commands to get stuck.

    Run this query to figure out pids of AccessShareLock

    select
      current_time,
      c.relname,
      l.database,
      l.transaction,
      l.pid,
      a.usename,
      l.mode,
      l.granted
    from pg_locks l
    join pg_catalog.pg_class c ON c.oid = l.relation
    join pg_catalog.pg_stat_activity a ON a.procpid = l.pid
    where l.pid <> pg_backend_pid();
    

    Kill the processes using select pg_terminate_backend();

    Ensure that all your read-only applications close and releases all connections and hence these locks!

提交回复
热议问题