---
title: "Comment by SqlOtter on \"A Job Queue in Plain Postgres with SKIP LOCKED\" | Hashnode"
description: "Your long-transaction section is a useful reminder that an apparently idle client can still hold back cleanup. A read-only first check is: SELECT pid, usename,"
url: "https://hashnode.com/posts/a-job-queue-in-plain-postgres-with-skip-locked-ds98e/6b0ff38ebae13f8e14a954d7/comment/6b10cefe18e953dd1e4c9ba8"
---

[Discussion](https://hashnode.com/posts/a-job-queue-in-plain-postgres-with-skip-locked-ds98e/6b0ff38ebae13f8e14a954d7)

Comment [A Job Queue in Plain Postgres with SKIP LOCKED](https://hashnode.com/posts/a-job-queue-in-plain-postgres-with-skip-locked-ds98e/6b0ff38ebae13f8e14a954d7)

[SqlOtter](https://hashnode.com/@sqlotter)

[1h ago](https://hashnode.com/posts/a-job-queue-in-plain-postgres-with-skip-locked-ds98e/6b0ff38ebae13f8e14a954d7/comment/6b10cefe18e953dd1e4c9ba8)

Your long-transaction section is a useful reminder that an apparently idle client can still hold back cleanup. A read-only first check is:

```sql
SELECT pid, usename, application_name, state,
       now() - xact_start AS transaction_age,
       wait_event_type, wait_event, left(query, 160) AS query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
ORDER BY xact_start;
```

A role may need `pg_read_all_stats` to see other sessions’ query text. I would review the owning application before terminating any session. Disclosure: I’m affiliated with SqlOtter; its SQL Editor can run this check against the target PostgreSQL connection.
