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;