public
Description: A Rails plugin to track database queries.
Homepage: http://code.google.com/p/query-stats/
Clone URL: git://github.com/dan-manges/query_stats.git
name age message
file .gitignore Sat Jul 12 14:54:35 -0700 2008 give query count in response header [dan-manges]
file CHANGELOG Sun Aug 24 16:25:03 -0700 2008 minor cleanup [dan-manges]
file README.rdoc Sun Aug 24 16:35:04 -0700 2008 tests also pass w/ mysql & rails 1.2.6 [dan-manges]
file Rakefile Mon Dec 01 13:08:56 -0800 2008 test with rails 2.2 [dan-manges]
file init.rb Sat Jul 12 15:36:33 -0700 2008 passing tests with mysql adapter on rails 2.1 [dan-manges]
directory lib/ Sun Aug 24 16:25:03 -0700 2008 minor cleanup [dan-manges]
directory test/ Sun Aug 24 16:04:59 -0700 2008 get rid of query_type state, determine type fro... [dan-manges]
README.rdoc

Query Stats Plugin

The Query Stats plugin tracks database queries.

Usage

Use the "queries" helper or controller method to access data on the queries. See the documentation on QueryStats::Holder for functionality.

You can easily display statistics in your page footer, such as:

  Queries in Controller: <%= queries.count_with_label :controller %>
  Queries in View:       <%= queries.count_with_label :view %>
  Query Time:            <%= queries.runtime %>

Logging

QueryStats adds the number of queries to the log in the DB section:

  Completed in 0.00642 (155 reqs/sec) | Rendering: 0.00228 (35%) | DB: 0.00247 (38%) 6 queries | 200 OK [http://test.host/]

Response Headers

  • X-QueryCount will be set to the number of queries
  • X-QueryRuntime will be set to the db runtime

Requirements

Tests pass with:

  • Rails: 1.2.6, 2.0.2, 2.1.0
  • Adapters: sqlite3, mysql

Maintainer

  • Dan Manges

Contributors

  • Guillaume Dufloux

License

Released under the MIT license.