Arlequin is a Ruby gem that helps detect and warn about N+1 SQL queries in Rails applications. It includes middleware that integrates seamlessly with your Rails application to improve performance by identifying inefficient database queries.
- N+1 Query Detection: Automatically detects and warns about N+1 query problems.
- Integration: Easy integration with Rails applications through a Railtie.
- Performance Insights: Provides detailed insights into query performance issues.
Add this line to your application's Gemfile:
gem 'arlequin', group: [ :development ]Then execute:
$ bundle installTo start using Arlequin, simply add the following to your Rails application’s configuration file (config/application.rb):
require 'arlequin'Arlequin integrates with Rails as middleware. It will automatically start monitoring SQL queries for N+1 problems. No additional setup is required beyond including it in your Gemfile and configuration.
Suppose you have a Rails application with a Post model that has many Comments. If you inadvertently write code like:
@posts = Post.all
@posts.each do |post|
puts post.comments.count
endArlequin will detect this N+1 query issue and warn you about it in the UI.
To contribute to Arlequin, clone the repository and run the test suite:
git clone https://github.com/dominicgoulet/arlequin.git
cd arlequin
bundle install
rake testMake sure to write tests for any new features or bug fixes you add. Follow the existing coding style and conventions used in the project.
We welcome contributions! Please submit pull requests and issues through GitHub. Ensure your code adheres to the project’s style and includes appropriate tests.
Arlequin is released under the MIT License.
For any questions or feedback, feel free to reach out to us at [[email protected]].