Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This rails plugin not only runs "EXPLAIN" before each of your select queries in development, but provides a small DIV in the rendered output of each page with the summary of query warnings that it analyzed.

branch: master

Add gemspec file for use with Bundler

Squashed commit of the following:

commit 7eaeb66
Author: Lee Bankewitz <lee@leebankewitz.com>
Date:   Mon Feb 7 16:13:09 2011 -0500

    fix gemspec

commit 81e77de
Author: Lee Bankewitz <lee@leebankewitz.com>
Date:   Mon Feb 7 16:09:57 2011 -0500

    gemspec
latest commit bb60d87383
lee lee authored February 08, 2011
Octocat-spinner-32 lib move tasks to lib/tasks to avoid rails deprecation warnings June 18, 2010
Octocat-spinner-32 test Rails 2.3.5 deprecates "activesupport" in favor of "active_support" December 02, 2009
Octocat-spinner-32 MIT-LICENSE initial revision December 09, 2007
Octocat-spinner-32 README ds: added mysql query profiling and all related features, also added … April 07, 2008
Octocat-spinner-32 Rakefile initial revision December 09, 2007
Octocat-spinner-32 init.rb be truly enabled or disabled December 17, 2008
Octocat-spinner-32 query_reviewer.gemspec Add gemspec file for use with Bundler February 08, 2011
Octocat-spinner-32 query_reviewer_defaults.yml ds: ability to disable the MYSQL and RAILS query caches during profiling May 09, 2008
README
QueryReviewer
=============

QueryReviewer is an advanced SQL query analyzer.  It accomplishes the following goals:

 * View all EXPLAIN output for all SELECT queries to generate a page (and optionally SHOW PROFILE ALL)
 * 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

All you have to do is install it.  You can optionally run:
  rake query_reviewer:setup

Which will create config/query_reviewer.yml, see below for what these options mean.  If you don't have a config file,
the plugin 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 (if you don't have real data, don't let query duration effect you!)

 * 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" verison of the stack trace should include files in /vendor
 * trace_includes_lib: whether the "short" verison 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, you'll need to manually put the analyzer's output into your view:

<%= query_review_output %>


Copyright (c) 2007-2008 Kongregate & David Stevenson, released under the MIT license
Something went wrong with that request. Please try again.