sql - postgres alter table 因连接池而挂起

标签 sql database postgresql connection-pooling ddl

执行简单的 alter table add column 挂起,这可能是因为我的应用程序使用连接池打开连接并可能锁定表。有什么方法可以在应用程序仍在运行时在 postgres 中执行 alter table 命令?

最佳答案

检查 View pg_locks 以查看哪个并发事务持有锁阻塞 ALTER TABLE

如果您的连接池保持连接挂起状态为“idle in transaction”(检查pg_stat_activity),则表明连接池或应用程序存在错误。你应该解决这个问题,因为它也会导致其他问题,比如因为 VACUUM 无法完成它的工作而导致的表膨胀。

Postgres Wiki 中提供了一组用于监视锁的语句:

关于sql - postgres alter table 因连接池而挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42663270/

相关文章:

c# - asp.net c# 连接到本地 Db vs2008

postgresql - 如何从线串postgis中获取积分

mysql - 使用基本连接进行多个值的 sql 查询

sql - Rails Activerecord 查询选择性包含

database - 动态配置Spring邮件发送器

database - 本地跳转错误 : unexpected return on all db queries after ugrading to rails 4

sql - 日期范围之间的 Postgresql 查询

sql - 当数组为空而没有动态sql时,Postgres sql返回所有

sql - 基于另一个行字段值更新字段

SQL用另一个表的记录更新一个表的记录?