【KingbaseES】V8R6查询长事务语句

ORACLE/SQLSQVER/MYSQL模式

powershell 复制代码
SELECT 
    CASE 
        WHEN xact_start IS NULL THEN '长连接' 
        ELSE '长事务' 
    END as backend_type,
    pid,
    sys_blocking_pids(pid) as blocking_pids,
    usename,
    query,
    xact_start,
    query_start,
    state,
    now() as current_time,
    *
FROM sys_stat_activity 
WHERE state <> 'idle' 
  AND (
    query_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
    OR 
    xact_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
  );

POSTGRESQL模式

powershell 复制代码
SELECT 
    CASE 
        WHEN xact_start IS NULL THEN '长连接' 
        ELSE '长事务' 
    END as backend_type,
    pid,
    pg_blocking_pids(pid) as blocking_pids,
    usename,
    query,
    xact_start,
    query_start,
    state,
    now() as current_time,
    *
FROM pg_stat_activity 
WHERE state <> 'idle' 
  AND (
    query_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
    OR 
    xact_start < (CURRENT_TIMESTAMP - '600 second'::INTERVAL)
  );
相关推荐
子超兄2 小时前
MVCC机制简介
数据库·mysql
虹科网络安全2 小时前
艾体宝洞察 | 在 Redis 之上,聊一聊架构思维
数据库·redis·架构
yuguo.im2 小时前
如何查看 Mysql 版本
数据库·mysql
中年程序员一枚2 小时前
让postman调用python的开发接口,链接sqlite数据库,让前后联动起来
数据库·python·postman
weixin_462446232 小时前
解决MongoDB官网下载过慢问题
数据库·mongodb
青蛙大侠公主2 小时前
Spring事务
java·数据库·spring
老华带你飞2 小时前
校务管理|基于springboot 校务管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·spring
zzz大王3 小时前
sql 五十题 26-30
数据库·sql
小尧嵌入式3 小时前
QT软件开发知识点流程及记事本开发
服务器·开发语言·数据库·c++·qt