SELECT procpid,start,now()-startASlap,current_query FROM (SELECT backendid,pg_stat_get_backend_pid(S.backendid)ASprocpid,pg_stat_get_backend_activity_start(S.backendid)ASstart,pg_stat_get_backend_activity(S.backendid)AScurrent_query FROM (SELECTpg_stat_get_backend_idset()ASbackendid)ASS )ASS WHERE current_query<>'<IDLE>' ORDERBY lapDESC;原文链接:https://www.f2er.com/postgresql/195630.html