postgresql - 如何打破postgresql中的连接池?

标签 postgresql

CREATE OR REPLACE FUNCTION add_() RETURNS void AS 
$BODY$ 
declare
    foo int; 
BEGIN

FOR i IN 1..50 LOOP         
    foo = i;
    RAISE NOTICE 'combination_array(%)', foo ;
    UPDATE table_1 set r_id = foo WHERE id = (select id from table_1 where r_id is null order by id limit 1); 
END LOOP;

END; $BODY$ LANGUAGE 'plpgsql' ;

SELECT add_();

每次执行后执行

UPDATE table_1 
   set r_id = foo 
WHERE id = (select id from table_1 where r_id is null order by id limit 1); 

END LOOP;

它会很忙,有人告诉我如何清除 pgsql 中的拉动

最佳答案

返回所有带id的连接

SELECT * from pg_stat_activity;

您可以通过以下查询通过 procpid 终止特定连接。

select pg_terminate_backend(procpid)
    from pg_stat_activity
    where datname = 'database-name'

关于postgresql - 如何打破postgresql中的连接池?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23015819/

相关文章:

javascript - 在 Postgres JSONB 中转义生成的单引号

sql - Postgres 从字符串运行 SQL 语句

postgresql - Postgresql 中的 NOT EXISTS 子句

postgresql - Postgres : delete all tables or cascade a delete?

php - 使用pgcrypto验证password_hash生成的密码

sql - Groupby排序和单行选择

postgresql - 授予对 postgresql 中 View 的访问权限

sql - 使用 WITH 和 CASE 更新 - PostgreSQL

ruby-on-rails - 点击服务器错误 : unitialized constant Config (migration from SQLite to Postgres)

spring - 在 Spring Boot 上使用 Hibernate 映射 PostGIS 几何点字段