Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Database Running Queries Monitoring Block for Svelte

Eight PostgreSQL sessions as rows with state, wait event and a duration bar against the 30 s statement timeout, a state filter, the full statement with a copy button and the lock chain to the session that blocks it.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

See what a database is doing right now and what is holding it up, with this running-queries panel for Svelte with Ark UI. It is Queryhound, a query monitor (made up), reading eight PostgreSQL sessions at 14:20 UTC. A hairline frame with a plus mark on each corner holds one row per session: the pid in mono, the statement cut to one line, how long it has run, its state word and a bar against a tick at the 30 s statement timeout. Solid bars are active, hatched is idle in a transaction and outlined is waiting for a lock. A Toggle Group in the header filters by state. Choosing a row fills the side cell with the full statement in mono, a Copy statement button, the wait event and the lock chain in a sentence; a waiting session has a button that selects the blocker. The header says how many sessions are blocked and by whom, worked out from the data. Guides draw the frame; the entrance is CSS only. For database on-call, slow-request triage and any team that chases a stuck update.

FAQ

How do I use my own sessions?

Edit SESSIONS at the top of the file: each entry has a pid, user, database, state (active, idle-in-tx or waiting), the seconds the statement or transaction has run at AS_OF_SECONDS, the wait event, the lock holder in blockedBy (0 for none) and the statement as an array of lines. In your app, fill it from pg_stat_activity joined with pg_blocking_pids() on the server and pass the rows in. The header, the lock chain and the bar lengths are all derived from these fields.

How does the blocker button work?

A session that waits for a lock carries the pid of the session that holds it. The side cell states the chain in a sentence ("4821 waits for 4812, which has been idle in a transaction for 9 minutes") and a button selects that blocker. If a filter hides the blocker the filter returns to All first, so the row you land on is always visible. A session that is not waiting never shows the button, but its space stays reserved so nothing moves.

What does the filter change?

It shows only the sessions in one state, and the list keeps its height so the side cell does not jump. Every state has at least one session in the demo, so the list never empties. The status line says how many sessions are showing.

What is real here and what stays local?

The sessions, durations and statements are typed examples and the product is made up; nothing connects to a database. Copy statement uses the real clipboard and says if the browser refuses. Nothing can be terminated or cancelled here: in your app, wire a cancel action to your own server behind a confirmation.

Can I read it without colour?

Yes. State is a word under each row, the bar fill is solid, hatched or outlined, a waiting row has a lock glyph, and the timeout tick has a caption under the list. Each row is a radio with a full spoken description, so arrow keys and a screen reader both work.

How does it look on a phone?

The rows keep their two lines (pid, statement and duration over the state and bar), the side cell stacks under the list, and the filter wraps under the header text.