NikolayS

NikolayS / pg_ash

Public

Active Session History for PostgreSQL — wait event sampling with zero bloat (pg_cron + PGQ-style partition rotation)

167
5
100% credibility
Found Feb 19, 2026 at 105 stars -- GitGems finds repos before they trend. Get early access to the next one.
Sign Up Free
AI Analysis
PLpgSQL
AI Summary

pg_ash is a pure SQL tool that samples database activity every second to reveal historical performance issues like top waits and queries in Postgres.

How It Works

1
🕵️ Notice database slowdowns

You feel your app slowing down and wonder what happened earlier when you weren't watching.

2
📥 Add the history tracker

Run a quick setup in your database to start recording activity snapshots without any hassle.

3
▶️ Begin capturing moments

Switch on the recorder to grab a picture of what's running every second.

4
📈 Spot the troublemakers

Pull up charts showing top slowdowns, busy queries, and wait patterns from the last hour.

5
🔍 Dig into details

Examine timelines, specific queries, or past incidents to understand exactly what went wrong.

Fix and feel the speed

Use your insights to tune queries or settings, and enjoy a smoother, faster database.

Sign up to see the full architecture

4 more

Sign Up Free

Star Growth

See how this repo grew from 105 to 167 stars Sign Up Free
Repurpose This Repo

Repurpose is a Pro feature

Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.

Unlock Repurpose
AI-Generated Review

What is pg_ash?

pg_ash delivers Oracle-style active session history to PostgreSQL by sampling pg_stat_activity every second via pg_cron, storing compact historical snapshots on disk for later SQL queries. Run ash.top_waits('1 hour') for top wait events with bar charts, or ash.activity_summary('5 minutes') for peak load breakdowns—pure PL/pgSQL, no C extensions or restarts needed. It rotates partitions daily to avoid bloat, keeping ~30 MiB/day even with 50 active sessions.

Why is it gaining traction?

Stands out for instant deployment on RDS, Supabase, or AlloyDB—no shared_preload_libraries like pg_wait_sampling, no external agents. Functions like ash.timeline_chart('1 hour') visualize spikes with stacked bars, and pg_stat_statements joins add query text/calls/times; absolute-time queries (ash.top_waits_at()) nail incident forensics. 81 stars reflect demand for zero-overhead active session history in managed Postgres.

Who should use this?

Postgres SREs and DBAs on managed services chasing "what blocked at 2am?" without ring-buffer memory limits. Prod teams mirroring Oracle's active session history for wait profiling, or operators dodging emergency flushes from undersized ASH setups.

Verdict

Grab it for lightweight historical monitoring—docs shine, 37/37 functions tested, benchmarks prove sub-50ms sampling. 1.0% credibility from low stars flags early maturity; test on staging first, but pure SQL makes it low-risk.

Sign up to read the full AI review Sign Up Free

Similar repos coming soon.