rails-pg-extras  by pawurb

Rails PG performance insights

created 5 years ago
1,215 stars

Top 33.0% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

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

  • Install via RubyGems: gem "rails-pg-extras"
  • Requires PostgreSQL extensions: pg_stat_statements (for query analysis) and pg_buffercache (for cache metrics). Enable with RailsPgExtras.add_extensions.
  • Optional: sslinfo extension for ssl_used check.
  • Connect to a specific database via ENV['RAILS_PG_EXTRAS_DATABASE_URL'].
  • Official Docs: https://github.com/pawurb/rails-pg-extras

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.
  • Optional web UI with configurable authentication and actions.

Maintenance & Community

The project is actively maintained by pawurb. Community interaction channels are not explicitly listed in the README.

Licensing & Compatibility

  • License: MIT
  • Compatible with Ruby on Rails applications.

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.

Health Check
Last commit

2 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
25 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.