rails-pg-extras  by pawurb

Rails PG performance insights

Created 5 years ago
1,226 stars

Top 32.1% 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

1 week ago

Responsiveness

1 day

Pull Requests (30d)
1
Issues (30d)
1
Star History
7 stars in the last 30 days

Explore Similar Projects

Starred by Morgan Funtowicz Morgan Funtowicz(Head of ML Optimizations at Hugging Face), Luis Capelo Luis Capelo(Cofounder of Lightning AI), and
7 more.

lighteval by huggingface

2.6%
2k
LLM evaluation toolkit for multiple backends
Created 1 year ago
Updated 1 day ago
Feedback? Help us improve.