rails-query-analyzer

Analyzes ActiveRecord queries for performance issues and suggests optimizations.

Updated Dec 8, 2022
One-click install
npx skills add https://github.com/lekemula/dotfiles --skill rails-query-analyzer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-query-analyzer
Source: https://github.com/lekemula/dotfiles/tree/main/claude/skills/rails-query-analyzer
Command: npx skills add https://github.com/lekemula/dotfiles --skill rails-query-analyzer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers identify and fix performance bottlenecks in their ActiveRecord database queries, leading to faster and more efficient applications.

Core Features & Use Cases

  • Performance Analysis: Reviews ActiveRecord queries for common performance anti-patterns.
  • Index Suggestions: Recommends and generates SQL for missing database indexes.
  • Query Rewrites: Provides optimized alternatives to inefficient query structures.
  • Use Case: A developer suspects a slow page load is due to inefficient database queries. They use this Skill to analyze the relevant code, get specific suggestions for optimization, and even generate the necessary migration files for new indexes.

Quick Start

Analyze the ActiveRecord queries in the file app/models/user.rb for performance issues.

Frequently Asked Questions about rails-query-analyzer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow ActiveRecord queries in Rails?

To optimize slow ActiveRecord queries, you can analyze your code to identify unindexed columns and inefficient select statements, receiving actionable query rewrites and migration code for missing indexes.

How can I find missing database indexes for Rails models?

Finding missing database indexes involves reviewing your ActiveRecord queries against the database schema to flag unindexed columns, which then generates the necessary SQL migration code to add them.

What is the best way to review SQL performance in a Rails application?

The best way to review SQL performance is to analyze ActiveRecord queries for common anti-patterns, enabling you to identify bottlenecks and apply optimized query structures for faster page loads.

Can I detect potential SQL injection risks during ActiveRecord query analysis?

Yes, you can detect potential SQL injection risks during query analysis by reviewing your ActiveRecord statements, allowing you to identify vulnerabilities alongside performance optimizations.

Do I need to provide the database schema to analyze Rails query performance?

Yes, providing the database schema is required to analyze Rails query performance accurately, as the review process checks queries against the schema to flag unindexed columns and suggest improvements.

What are common ActiveRecord anti-patterns that cause database bottlenecks?

Common ActiveRecord anti-patterns causing database bottlenecks include inefficient select statements and querying unindexed columns, which can be resolved by applying suggested query rewrites and generated index migrations.