Rails PG performance insights
Top 33.0% on sourcepulse
This gem provides Ruby on Rails developers with comprehensive PostgreSQL database performance insights, including lock analysis, index usage, buffer cache hit ratios, and vacuum statistics. It offers both Rake tasks and a Ruby API for easy integration into monitoring workflows, aiming to simplify performance tuning for Rails applications not relying on Heroku's PG Extras.
How It Works
The tool leverages PostgreSQL's built-in statistics views and extensions like pg_stat_statements
, pg_buffercache
, and sslinfo
to gather detailed performance metrics. It presents this data through various Rake tasks and Ruby methods, allowing developers to diagnose issues like N+1 queries, missing indexes, and inefficient cache utilization. An optional web interface is also available for a visual overview.
Quick Start & Requirements
gem "rails-pg-extras"
pg_stat_statements
(for query analysis) and pg_buffercache
(for cache metrics). Enable with RailsPgExtras.add_extensions
.sslinfo
extension for ssl_used
check.ENV['RAILS_PG_EXTRAS_DATABASE_URL']
.Highlighted Details
measure_queries
method helps identify N+1 problems by analyzing query execution within Ruby code blocks.missing_fk_indexes
and missing_fk_constraints
identify potential performance bottlenecks and data integrity issues.diagnose
provides a consolidated report of potential performance problems.Maintenance & Community
The project is actively maintained by pawurb. Community interaction channels are not explicitly listed in the README.
Licensing & Compatibility
Limitations & Caveats
Some advanced features, like query analysis and outlier detection, depend on the pg_stat_statements
extension being enabled and configured in PostgreSQL. The README mentions a rails-pg-extras-mcp
gem for LLM support, indicating potential future integrations or separate components.
2 weeks ago
Inactive