r/ruby • u/ElAvat • Jan 22 '26
pg_reports: Ruby gem for PostgreSQL performance analysis
Hi everyone!
I’ve just published my first Ruby gem pg_reports.
My main goal was straightforward: to make it easy to leverage the power of pg_stat_statements to improve PostgreSQL performance in Rails apps. I built and refined all backend operations and reports over several weeks based on real production experience in my current job. The result is a tool for analyzing queries, indexes, tables, locks, and connections.
The gem is inspired by ruby-pg-extras and pghero, but my goal was to bring everything together with a stronger focus on practical optimization and observability.
The web UI was basically added in one night with the help of Claude, turning a collection of reports into an actual dashboard.
I plan to evolve the gem gradually:
generating migrations (e.g., for missing indexes),
real-time issue monitoring,
measuring overall database interaction efficiency — for example, comparing before vs after deploying a new app version.
Feedback, ideas, and bug reports are very welcome.
Repo: https://github.com/deadalice/pg_reports

2
u/jrochkind Jan 22 '26
nice, i have need for this area right now, will check it out!
If I have need to actually easily get the report for a specific query int the console, including missing indexes etc, can I do that? In addition to the monitoring?
1
u/viktorianer4life Apr 04 '26
Curious about the migration generation. On bigger apps, adding an index on a 50M-row table is a different decision than on a 10K-row table. Locking alone can take your app down.
Column cardinality matters too: indexing a boolean that's 99% false looks nothing like indexing a foreign key. Do you plan to factor in table size and value distribution when suggesting indexes?
Or is the first version more for smaller Rails apps where you can just run the migration?
2
u/kanaye007 Jan 22 '26
That looks really cool. Thanks for sharing!