Example: long query running script
postgres=> SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes' and state = 'active'
ORDER BY duration DESC NULLS LAST;
pid | duration | query | state
-------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------
24019 | 01:59:17.685468 | select launch0_.id as id1_9_, launch0_.approximate_duration as approxim2_9_, launch0_.description as descript3_9_, launch0_.end_time as end_time4_9_, launch0_.has_retries as has_retr5_9_, launch0_.last_modified as last_mod6_9_, launch0_.mode as mode7_9_, launch0_.name as name8_9_, launch0_.number as number9_9_, launch0_.project_id as project10_9_, launch0_.rerun as rerun11_9_, launch0_.start_time as start_t12_9_, launch0_.status as status13_9_, launch0_.user_id as user_id14_9_, launch0_.uuid as uuid15_9_ from public.launch launch0_ where launch0_.uuid=$1 for update of launch0_ | active
24081 | 01:56:16.740649 | select launch0_.id as id1_9_, launch0_.approximate_duration as approxim2_9_, launch0_.description as descript3_9_, launch0_.end_time as end_time4_9_, launch0_.has_retries as has_retr5_9_, launch0_.last_modified as last_mod6_9_, launch0_.mode as mode7_9_, launch0_.name as name8_9_, launch0_.number as number9_9_, launch0_.project_id as project10_9_, launch0_.rerun as rerun11_9_, launch0_.start_time as start_t12_9_, launch0_.status as status13_9_, launch0_.user_id as user_id14_9_, launch0_.uuid as uuid15_9_ from public.launch launch0_ where launch0_.uuid=$1 for update of launch0_ | active
20673 | 01:50:14.737422 | select launch0_.id as id1_9_, launch0_.approximate_duration as approxim2_9_, launch0_.description as descript3_9_, launch0_.end_time as end_time4_9_, launch0_.has_retries as has_retr5_9_, launch0_.last_modified as last_mod6_9_, launch0_.mode as mode7_9_, launch0_.name as name8_9_, launch0_.number as number9_9_, launch0_.project_id as project10_9_, launch0_.rerun as rerun11_9_, launch0_.start_time as start_t12_9_, launch0_.status as status13_9_, launch0_.user_id as user_id14_9_, launch0_.uuid as uuid15_9_ from public.launch launch0_ where launch0_.uuid=$1 for update of launch0_ | active
20702 | 01:26:06.933601 | select launch0_.id as id1_9_, launch0_.approximate_duration as approxim2_9_, launch0_.description as descript3_9_, launch0_.end_time as end_time4_9_, launch0_.has_retries as has_retr5_9_, launch0_.last_modified as last_mod6_9_, launch0_.mode as mode7_9_, launch0_.name as name8_9_, launch0_.number as number9_9_, launch0_.project_id as project10_9_, launch0_.rerun as rerun11_9_, launch0_.start_time as start_t12_9_, launch0_.status as status13_9_, launch0_.user_id as user_id14_9_, launch0_.uuid as uuid15_9_ from public.launch launch0_ where launch0_.uuid=$1 for update of launch0_ | active