Activerecord

Different Approaches to Debugging Query Performance in Rails

A comprehensive guide to debugging and optimizing query performance in Rails applications using built in tools, gems, and database specific utilities for PostgreSQL, MySQL, and SQLite.

Rails 7.2 pluck and pick Accept Hash for Joins

Rails 7.2 lets pluck and pick accept hash values to specify columns from joined tables without raw SQL.

Rails 7.1 explain Accepts Options

Adding analyze and verbose as ActiveRecord::Relation#explain options give us deeper insight into query performance.

Rails 7.1 ActiveRecord regroup Method

With regroup and regroup! methods we can override the group_values

Rails 7.1 allows resetting singular

Query database again to retrieve the associated record by resetting the cache on singular associations.

Rails 7.1 Disable Enum Auto-Methods

Disable auto generated methods of ActiveRecord.enum with instance_methods by passing false to it.

Rails 7.1 reselect Accepts Hash Values

Use of hash syntax for specifying columns and aliases with the ActiveRecord::QueryMethods#reselect method makes it easier for querying.

Rails 7.1 Async Query Support in ActiveRecord

With the Active Record API for general async queries we can efficiently query not so fast queries asynchronously to improve the performance.

Rails 7.1 generates_token_for Method

Generate tokens for specific purposes and verify their authenticity.

Rails 7.1 ActiveRecord Normalization

Rails 7.1 lets you define custom normalization rules for model attributes with the normalizes method.