As with any performance advice, the only way to really improve things is to try
things out and measure.
Find long-running queries
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
usename,
query,
state,
wait_event_type,
wait_event
FROM pg_stat_activity
WHERE
state = 'active'