# pg-tools **Repository Path**: tangjunhu/pg-tools ## Basic Information - **Project Name**: pg-tools - **Description**: 用于postgresql运维工具 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-05 - **Last Updated**: 2026-10-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pg-tools #### 介绍 用于postgresql运维工具 #### 使用说明 # 只打印dry‑run,找出运行超过30秒活跃SQL python3 pg_kill.py --host=127.0.0.1 --user=postgres --password="xxx" --busy-time 30 # 取消查询(不杀连接),杀掉运行超过20s select语句,后台daemon,每5秒采样 python3 pg_kill.py --host=127.0.0.1 --user=postgres --password="xxx" --busy-time 20 --match-query="SELECT" --kill-query --daemonize # 直接terminate干掉idle超过600s空闲会话 python3 pg_kill.py --host=127.0.0.1 --user=postgres --password="xxx" --idle-time 600 --kill # 多条件 |分隔 python3 pg_kill.py --match-user="app1|app2" --match-state="active|idle in transaction" --busy-time 40