nesquena/query_reviewer sits at 554 stars on GitHub, written primarily in Ruby. An excellent development aid. Will run "EXPLAIN" before each of your select queries in development, and provides a display which makes them easy to browse. In this fork, gemified and compatible with Rails 2 + 3.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
QueryReviewer is an advanced SQL query analyzer. It accomplishes the following goals:
View all EXPLAIN output for all SELECT queries to generate a page
Rate a page's SQL usage into one of three categories: OK, WARNING, CRITICAL
Attach meaningful warnings to individual queries, and collections of queries
Display interactive summary on page
Use This Fork
I use this utility for most of my MySQL-backed Rails projects. Still the best out there in my opinion for analyzing and understanding your generated SQL queries.
I forked the original query_reviewer and applied a collection of patches that have been made since the plugin was created.
A list of the biggest additions below:
Snazzed up the README into markdown for better readability
Full compatibility for Rails 3 (including Railtie)
Cleanup and move rake task to lib/tasks to fix deprecation warnings
Added gemspec for use with Bundler (as a gem)
Fixed missing tags and additional XHTML escaping
Fix SQL escaping for better XHTML compatibility
Fixes for deprecation warnings and for 1.9 compatiblity
Converts templates to more modern foo.html.erb naming
As of August 2011, This has become the "official" version to use. David has deprecated the original repo and recommends that people looking for this utility use this fork instead.
This fork compiles a variety of patches that were made since that time along with additional work to support compatibility with 1.9 and Rails 3.
Also: If anyone else creates generally useful enhancements to this utility please start by forking this and then issue me a pull request.
Note: This plugin should work for Rails 2.X and Rails 3. If you run into issues, please file a bug report or send a pull request. I consider this new fork to be a group effort
so if you want to be added as a contributor to help maintain this, please let me know!
Database Limitations
As of right now, this plugin supports analyzing queries only for MySQL. I consider this the primary limitation of this gem.
I am now using PostgreSQL for a number of my projects and the "EXPLAIN" output is totally different. Several people have started a PostgreSQL adapter for
this plugin, but none that are mature enough to include here.
If anyone is interested at taking a stab at implementing PostgreSQL support for this utility, that would be hugely appreciated! I hope this plugin can come to support
all the major Rails adapters over time.
Installation
All you have to do is install it into your Rails 2 or 3 project.
gem install query_reviewer
Right now if you use bundler, simply add this to your Gemfile:
In Rails 2, the rake tasks are not loaded automatically (as a gem), you’ll need to add the following to your Rakefile:
# Rakefile
begin
require 'query_reviewer/tasks'
rescue LoadError
STDERR.puts "The query_reviewer gem could not be found!"
end
You can then run:
$ rake query_reviewer:setup
Which will create config/query_reviewer.yml in your application, see below for what these options mean.
If you don't create a config file, the gem will use the default in vendor/plugins/query_reviewer.
Configuration
The configuration file allows you to set configuration parameters shared across all rails environment, as well as overriding those shared parameteres with environment-specific parameters (such as disabling analysis on production!)
enabled: whether any output or query analysis is performed. Set this false in production!
inject_view: controls whether the output automatically is injected before the </body> in HTML output.
profiling: when enabled, runs the MySQL SET PROFILING=1 for queries longer than the warn_duration_threshold / 2.0
production_data: whether the duration of a query should be taken into account
stack_trace_lines: number of lines of call stack to include in the "short" version of the stack trace
trace_includes_vendor: whether the "short" version of the stack trace should include files in /vendor
trace_includes_lib: whether the "short" version of the stack trace should include files in /lib
warn_severity: the severity of problem that merits "WARNING" status
critical_severity: the severity of problem that merits "CRITICAL" status
warn_query_count: the number of queries in a single request that merits "WARNING" status
critical_query_count: the number of queries in a single request that merits "CRITICAL" status
warn_duration_threshold: how long a query must take in seconds (float) before it's considered "WARNING"
critical_duration_threshold: how long a query must take in seconds (float) before it's considered "CRITICIAL"
Example
If you disable the inject_view option above, you'll need to manually put the analyzer's output into your view:
# view.html.haml
= query_review_output
and that will display the analyzer view!
Resources
Random collection of resources that might be interesting related to this utility:
Other related gems that prove useful for database optimization:
bullet
slim-scrooge
slim-attributes
Alternatives
There have been other alternatives created since this was originally released. A few of the best are listed below. I for one still prefer this utility over the other options:
rack-bug
rails-footnotes
newrelic-development
palmist
query_diet
query_trace
Know of a better alternative? Let me know!
Acknowledgements
Created by Kongregate & David Stevenson. Refactorings and maintenance done by Nathan Esquenazi.
Also @ajvargo helped with several fixes.
Copyright (c) 2007-2008 Kongregate & David Stevenson, released under the MIT license
TopGit's last sync did not record any GitHub topics for nesquena/query_reviewer. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on nesquena/query_reviewer?
The most recent commit recorded on nesquena/query_reviewer was 12.9 years ago, based on the GitHub push timestamp. The repository has 36 forks — one of the better signals of community interest.
How many stars does nesquena/query_reviewer have?
nesquena/query_reviewer has 554 GitHub stars — refresh the page for the live number, or check github.com/nesquena/query_reviewer. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is nesquena/query_reviewer open source?
Yes — nesquena/query_reviewer ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/nesquena/query_reviewer.
Where can I see nesquena/query_reviewer in action?
The project maintains a homepage at http://code.google.com/p/query-reviewer/. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about nesquena/query_reviewer?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/nesquena/query_reviewer is the definitive source.
Read full README in the tab above.
Still deciding about query_reviewer?
One click hands the question to an AI along with this page — see what it says about query_reviewer.