performance-optimization

Detect and fix inefficient ActiveRecord data access patterns in Rails applications.

7|3|Updated May 25, 2015
One-click install
npx skills add https://github.com/rockcodelabs/kw-app --skill performance-optimization-rockcodelabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-optimization
Source: https://github.com/rockcodelabs/kw-app/tree/main/.agents/skills/performance-optimization
Command: npx skills add https://github.com/rockcodelabs/kw-app --skill performance-optimization-rockcodelabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Rails developers identify and fix inefficient data access patterns, reducing latency and database load by addressing common bottlenecks like N+1 queries, missing indexes, and stale caches.

Core Features & Use Cases

  • N+1 query detection and prevention with practical Rails patterns
  • Eager loading and query optimization using includes, preload, eager_load, and joins
  • Database indexing guidance to speed up lookups and filters
  • Caching strategies (fragment, collection, Russian-doll) to reduce recomputation
  • Batch processing and efficient data handling for large datasets

Quick Start

Run a quick performance audit on your Rails app in development: enable Bullet, identify N+1 hotspots, apply includes where needed, add missing indexes, and validate improvements by rerunning representative queries.

Frequently Asked Questions about performance-optimization

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

FAQPage Schema
How do I fix N+1 queries in Rails?

Fix N+1 queries in Rails by using eager loading methods like includes, preload, and eager_load to batch database queries. Detect these inefficient data access patterns using the Bullet gem in development.

What is the difference between includes, preload, and eager_load in Rails?

In Rails eager loading, preload fetches associations in separate queries, eager_load forces a single JOIN query, and includes dynamically chooses between them based on query conditions to optimize data access.

How do I run a performance audit on a Rails application?

Run a Rails performance audit by enabling Bullet to identify N+1 query hotspots, applying eager loading, adding missing database indexes for lookups, and validating improvements by rerunning representative queries.

What caching strategies can I use to reduce latency in Rails?

Reduce Rails latency by implementing caching strategies like fragment caching, collection caching, and Russian-doll caching to minimize recomputation and lower database load across development and production environments.

Does this Rails performance optimization approach apply to production environments?

Yes, these Rails performance optimization patterns apply across development, staging, and production environments to detect inefficient data access, add database indexes, and implement caching to reduce database load.

When should I use batch processing for large datasets in Rails?

Use batch processing in Rails when handling large datasets to ensure efficient data processing, reduce memory overhead, and minimize database load during bulk ActiveRecord operations and background jobs.