PG 查询命令执行时间

枚举


-- 创建枚举值
CREATE TYPE xxxx AS ENUM ('A', 'D');

-- 添加枚举值
ALTER TYPE xxxx ADD VALUE '';

-- 列出枚举值
SELECT enumlabel
FROM pg_type t
JOIN pg_enum e ON t.oid = e.enumtypid
WHERE t.typname = 'xxxx'
ORDER BY e.enumsortorder;

-- 插入枚举时,按普通字符串一样插入即可
http://www.postgres.cn/docs/9.3/datatype-enum.html

查询命令执行时间

select pid,query,query_start, now()-query_start as "runtime",state from pg_stat_activity where state not like "%idle%" order by "runtime" desc

# https://www.cnblogs.com/yulinlewis/p/11863750.html
# 查找被锁住的查询
select * from pg_locks a
join pg_class b on a.relation = b.oid
join pg_stat_activity c on a.pid = c.pid
where a.mode like '%ExclusiveLock%';

# https://help.aliyun.com/zh/rds/support/how-to-troubleshoot-high-cpu-utilization-of-apsaradb-rds-for-postgresql
# https://www.cnblogs.com/abclife/p/16440056.html
# https://docs.aws.amazon.com/zh_cn/redshift/latest/dg/PG_CANCEL_BACKEND.html
# https://cloud.tencent.com/developer/article/2119089
# https://blog.51cto.com/u_13126942/2047679
上一篇
下一篇