debugging - How to use pg_stat_activity? -


i'd see queries being executed on live django application, , how memory taking up. have read pg_stat_activity can useful monitor postgres database.

i have looked @ postgres documentation, have simple question doesn't seem answered there.

how started pg_stat_activity? type use it, , type it?

see this closely related answer.

pg_stat_activity view in pg_catalog schema.

you can query selecting other table, eg select * pg_stat_activity. manual page linked explains columns.

you'll find wanting join on other tables pg_class (tables), pg_namespace (schemas), etc.

pg_stat_activity not expose information back-end memory use. need use operating-system level facilities that. does tell process id, active user, running query, activity status, time last query started, etc. it's identifying long-running idle in transaction sessions, long running queries, etc.

frankly, postgresql's built-in monitoring rather rudimentary. it's 1 of areas that's not exciting work on, , commercial clients aren't willing fund it. people couple tools check_postgres icinga , munin, or use zabbix or other external monitoring agents.

in case sounds want pg_stat_statements, and/or pgbadger log analysis suitable logging settings , possibly auto_explain module.


Comments