Tracing von Sessions in der Datenbank
Mit diesen beiden Statements kann man die aktuellen SQL Sessions in der Datenbank herausbekommen:
SELECT pid, age(clock_timestamp(), query_start), usename, query FROM pg_stat_activity WHERE query != '<IDLE>' AND query NOT LIKE '%pg_stat_activity%' ORDER BY query_start desc; |
SELECT pid, state, backend_start, substr(query, 0, 100) q FROM pg_stat_activity WHERE backend_type = 'client backend' ORDER BY backend_start; |