This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- CHECK TIMINGS ON ACTIVE AND EXPENSIVE QUERIES | |
SELECT activity.* | |
FROM ( | |
SELECT | |
pid, | |
CASE WHEN state = 'active' THEN AGE(clock_timestamp(), query_start) | |
ELSE AGE(state_change, query_start) | |
END as query_duration, -- This is how long the most recent query was running (or is running so far, if still active) | |
AGE(clock_timestamp(), xact_start) as xact_duration, -- Same, but for the currently active transaction | |
CASE WHEN state = 'active' THEN INTERVAL '0' |