GP - To gather orphan process information

Generating the report of process and checking if the total segments = total sessions
SELECT
 'con'|| a.mppsessionid AS "Session ID",
 b.total_seg AS "Total Segments",
 count(a.*) AS "Total Sessions"
FROM
 (SELECT DISTINCT mppsessionid, gp_segment_id  
  FROM pg_locks 
  WHERE mppsessionid not in 
    (SELECT sess_id 
     FROM pg_stat_activity 
     WHERE procpid!=pg_backend_pid() 
     OR current_query!='' 
     OR waiting='t') 
  AND mppsessionid != 0 
 ) a,
 (SELECT COUNT(*) AS total_seg FROM gp_segment_configuration WHERE role='p') b
GROUP BY 1,2
HAVING COUNT(a.*) < b.total_seg
ORDER BY 3;
NOTE: Run this SQL from postgres database

Comments

Popular posts from this blog

GP - Kerberos errors and resolutions

How to set Optimizer at database level in greenplum

GP - SQL Joins